Skip to content

Commit

Permalink
Fix corner-case disk resource ordering issue
Browse files Browse the repository at this point in the history
when scsi reservation is active and disk resources with different digit lengths
are defined, the alphanumeric ordering might be broken.
  • Loading branch information
cvaroqui committed Aug 7, 2018
1 parent e000587 commit 7b65abf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions lib/resScsiReserv.py
Expand Up @@ -33,6 +33,7 @@ def __init__(self,
rid=rid+"pr",
type="disk.scsireserv",
**kwargs)
self.sort_key = rid

def mangle_devs(self, devs):
"""
Expand Down
21 changes: 14 additions & 7 deletions lib/resources.py
Expand Up @@ -24,6 +24,11 @@
"set_unprovisioned",
]

LOCKER_TYPES = [
"disk.scsireserv",
"disk.lock",
]

class Resource(object):
"""
Resource drivers parent class
Expand Down Expand Up @@ -165,15 +170,17 @@ def __lt__(self, other):
Resources needing to be started or stopped in a specific order
should redefine that.
"""
if self.rid+"pr" == other.rid:
return False
elif self.rid == other.rid+"pr":
return True
if self.type in LOCKER_TYPES and other.type not in LOCKER_TYPES:
ret = True
elif self.type not in LOCKER_TYPES and other.type in LOCKER_TYPES:
ret = False
elif self.type == "sync.zfssnap" and other.type == "sync.zfs":
return True
ret = True
elif self.type == "sync.zfs" and other.type == "sync.zfssnap":
return False
return self.sort_key < other.sort_key
ret = False
else:
ret = self.sort_key < other.sort_key
return ret

def save_exc(self):
"""
Expand Down

0 comments on commit 7b65abf

Please sign in to comment.