Skip to content

Commit

Permalink
mgr/volumes: move up 'confirm' validation
Browse files Browse the repository at this point in the history
Instead of checking if the --yes-i-really-mean-it
flag was set _after_ removing the MDS daemon, we
need to check if before starting any removal operation.

Fixes: https://tracker.ceph.com/issues/42931
Signed-off-by: Joshua Schmid <jschmid@suse.de>
  • Loading branch information
Joshua Schmid committed Nov 21, 2019
1 parent e4b3036 commit c1db7f8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/pybind/mgr/volumes/fs/volume.py
Expand Up @@ -257,13 +257,7 @@ def create_filesystem(self, fs_name, metadata_pool, data_pool):
'data': data_pool}
return self.mgr.mon_command(command)

def remove_filesystem(self, fs_name, confirm):
if confirm != "--yes-i-really-mean-it":
return -errno.EPERM, "", "WARNING: this will *PERMANENTLY DESTROY* all data " \
"stored in the filesystem '{0}'. If you are *ABSOLUTELY CERTAIN* " \
"that is what you want, re-issue the command followed by " \
"--yes-i-really-mean-it.".format(fs_name)

def remove_filesystem(self, fs_name):
command = {'prefix': 'fs fail', 'fs_name': fs_name}
r, outb, outs = self.mgr.mon_command(command)
if r != 0:
Expand Down Expand Up @@ -319,6 +313,12 @@ def delete_volume(self, volname, confirm):
if self.stopping.isSet():
return -errno.ESHUTDOWN, "", "shutdown in progress"

if confirm != "--yes-i-really-mean-it":
return -errno.EPERM, "", "WARNING: this will *PERMANENTLY DESTROY* all data " \
"stored in the filesystem '{0}'. If you are *ABSOLUTELY CERTAIN* " \
"that is what you want, re-issue the command followed by " \
"--yes-i-really-mean-it.".format(volname)

self.purge_queue.cancel_purge_job(volname)
self.connection_pool.del_fs_handle(volname, wait=True)
# Tear down MDS daemons
Expand All @@ -337,7 +337,7 @@ def delete_volume(self, volname, confirm):
# In case orchestrator didn't tear down MDS daemons cleanly, or
# there was no orchestrator, we force the daemons down.
if self.volume_exists(volname):
r, outb, outs = self.remove_filesystem(volname, confirm)
r, outb, outs = self.remove_filesystem(volname)
if r != 0:
return r, outb, outs
else:
Expand Down

0 comments on commit c1db7f8

Please sign in to comment.