Skip to content

Commit

Permalink
Fix a stack sorting fs.dir and fs.flag resources in the same object
Browse files Browse the repository at this point in the history
Catch AttributeError from resFs __lt__ when comparing mount_point attrs, as
this attribute may not exist in all fs drivers (ex: fs.flag).

Resync the resFsDir __lt__ definition from resFs.

Do not return the first fs resource mount point as the volume mount point, as
the first fs resource might not have a mount_point attribute. Return the
mount point of the first fs resource with a mount_point attribute instead.
  • Loading branch information
cvaroqui committed Feb 12, 2020
1 parent 512c999 commit b46bcaa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
7 changes: 5 additions & 2 deletions lib/resFs.py
Expand Up @@ -236,8 +236,11 @@ 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)
try:
smnt = os.path.dirname(self.mount_point)
omnt = os.path.dirname(other.mount_point)
except AttributeError:
return self.rid < other.rid
return (smnt, self.rid) < (omnt, other.rid)

@lazy
Expand Down
14 changes: 8 additions & 6 deletions lib/resFsDir.py
Expand Up @@ -125,10 +125,12 @@ def __str__(self):

def __lt__(self, other):
"""
Order so that deepest mountpoint can be umount first
Order so that deepest mountpoint can be umount first.
If no ordering constraint, honor the rid order.
"""
return self.mount_point < other.mount_point




try:
smnt = os.path.dirname(self.mount_point)
omnt = os.path.dirname(other.mount_point)
except AttributeError:
return self.rid < other.rid
return (smnt, self.rid) < (omnt, other.rid)
6 changes: 5 additions & 1 deletion lib/svc.py
Expand Up @@ -5612,7 +5612,11 @@ def mount_point(self):
candidates = [res for res in self.get_resources("fs")]
if not candidates:
return
return sorted(candidates)[0].mount_point
for candidate in sorted(candidates):
if not hasattr(candidate, "mount_point"):
continue
return candidate.mount_point
raise IndexError

def device(self):
"""
Expand Down

0 comments on commit b46bcaa

Please sign in to comment.