Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tweak the fs ordering algorithm
If two fs resources have mount points in the same parent directory, sort them
by rid instead of alphanum.

The typical use case is:

fs#1.mnt = /srv/{svcname}/docker
fs#1.size = 4g
fs#2.mnt = /srv/{svcname}/data
fs#2.size = 100%FREE

Here you want to be able to force fs#1 provision to run before fs#2, so the
100%FREE is evaluated last. But a pure alphanum sort on mnt causes fs#2 to
be provisioned first.

With this patch, fs#1 and fs#2 mnt being both in the same /srv/{svcname}/
dir, they get ordered by rid.
  • Loading branch information
cvaroqui committed Feb 4, 2018
1 parent 8b4e3e0 commit ab5fadf
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/resFs.py
Expand Up @@ -212,7 +212,12 @@ def __str__(self):
def __lt__(self, other):
"""
Order so that deepest mountpoint can be umount first.
If no ordering constraint, honor the rid order.
"""
smnt = os.path.dirname(self.mount_point)
omnt = os.path.dirname(other.mount_point)
if smnt == omnt:
return Res.Resource.__lt__(self, other)
return self.mount_point < other.mount_point

@lazy
Expand Down

0 comments on commit ab5fadf

Please sign in to comment.