Skip to content

Commit

Permalink
correct logical error on removing mdraid member role rockstor#1294
Browse files Browse the repository at this point in the history
Previously we only alterred the mdraid member flag to a disks role
when it's fstype, as reported by scan_disks, indicated the need.
However this was done within a conditional that precluded
examining a 'None' fstype which is what scan_disks translates an
empty string into. Hence we never updated a role db entry for a
previous mdraid member once that member no longer returned an
fstype. Resolved by moving the role label logic outside the
previous conditional such that it now applies to all disks even if
they return no fstype from scan_disks.
Also added debug logging to help test this new arrangement.
  • Loading branch information
phillxnet committed May 8, 2016
1 parent cb0ebf8 commit dbaefa0
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/rockstor/storageadmin/views/disk.py
Expand Up @@ -122,21 +122,23 @@ def _update_disk_state():
dob.parted = True # overload use of parted as non btrfs flag.
# N.B. this overload use may become redundant with the addition
# of the Disk.role field.
if d.fstype == 'isw_raid_member' \
or d.fstype == 'linux_raid_member':
# transfer fstype raid member indicator to role field
dob.role = d.fstype
else:
# No identified role from scan_disks() fstype indicator so
# set as None to update db of new drive role. If we don't
# do this then the same drive when re-deployed will inherit
# it's previous role in the db which may be desired but in
# the case of these raid member indicators from scan_disks()
# we have the current truth provided.
# N.B. this if else could be expanded to accommodate other
# roles based on the fs found and also take heed of an
# existing devices db role entry prior to overwriting.
dob.role = None
if d.fstype == 'isw_raid_member' or d.fstype == 'linux_raid_member':
# transfer fstype raid member indicator to role field
dob.role = d.fstype
logger.debug('setting db role for %s', dob.name)
logger.debug('to role = %s', dob.role)
else:
# No identified role from scan_disks() fstype indicator so
# set as None to update db of new drive role. If we don't
# do this then the same drive when re-deployed will inherit
# it's previous role in the db which may be desired but in
# the case of these raid member indicators from scan_disks()
# we have the current truth provided.
# N.B. this if else could be expanded to accommodate other
# roles based on the fs found and also take heed of an
# existing devices db role entry prior to overwriting.
dob.role = None
logger.debug('setting db role to None for %s', dob.name)
# If our existing Pool db knows of this disk's pool via it's label:
if (Pool.objects.filter(name=d.label).exists()):
# update the disk db object's pool field accordingly.
Expand Down

0 comments on commit dbaefa0

Please sign in to comment.