Skip to content

Commit

Permalink
Merge pull request #2184 from phillxnet/2099_failure_to_remove_detach…
Browse files Browse the repository at this point in the history
…ed_disks_via_pool_resize

failure to remove detached disks via pool resize. Fixes #2099
  • Loading branch information
phillxnet authored Jun 24, 2020
2 parents 2c088c1 + 62c9093 commit f23bef5
Show file tree
Hide file tree
Showing 3 changed files with 454 additions and 286 deletions.
25 changes: 24 additions & 1 deletion src/rockstor/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,30 @@ def start_resize_pool(cmd):
:param cmd: btrfs dev add/delete command in run_command() format (ie list).
"""
logger.debug("Resize pool command ({}).".format(cmd))
run_command(cmd)
# N.B. in some instances, such as live disk removal, an attempt to remove missing:
# btrfs device delete missing /mnt2/pool-label
# results in rc=1, out=[""], and err=
# ["ERROR: error removing device 'missing': no missing devices found to remove", '']
# return advice, in this case, to improve usability. Customised exception message is
# presented in Pool details page - Balances tab, Errors or Notes column.
try:
run_command(cmd, log=True)
except CommandException as e:
emsg = (
"ERROR: error removing device 'missing': no missing devices found to remove"
)
if e.err[0] == emsg:
msg = (
"Missing Device removal failed, ensure degraded,rw mount options are used "
"(a reboot may be required)."
)
logger.error(msg)
raise Exception(
"{} Command was ({}). Command Exception was ({}).".format(
msg, " ".join(cmd), emsg
)
)
raise e


@task()
Expand Down
10 changes: 10 additions & 0 deletions src/rockstor/storageadmin/views/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ def _refresh_pool_state():
"are no attached devices. Moving on.".format(p.name)
)
continue
# If pool has no missing remove all detached disk pool associations.
# Accounts for 'end of run' clean-up in removing a detached disk and for cli
# maintenance re pool returned to no missing dev status. Also re-establishes
# pool info as source of truth re missing.
if not p.has_missing_dev:
for disk in p.disk_set.filter(name__startswith="detached-"):
logger.info("Removing detached disk from Pool {}: no missing "
"devices found.".format(p.name))
disk.pool = None
disk.save()
try:
# Get and save what info we can prior to mount.
first_dev = p.disk_set.attached().first()
Expand Down
Loading

0 comments on commit f23bef5

Please sign in to comment.