From: Joshua Schmid Date: Wed, 20 Nov 2019 13:58:47 +0000 (+0100) Subject: mgr/volumes: move up 'confirm' validation X-Git-Tag: v14.2.8~49^2~31 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f2304fdb3ba85d59f9dcb1045d74d196677071ca;p=ceph.git mgr/volumes: move up 'confirm' validation 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 (cherry picked from commit c1db7f8b42f238f5875386a71d30bc34ae29171c) --- diff --git a/src/pybind/mgr/volumes/fs/volume.py b/src/pybind/mgr/volumes/fs/volume.py index 0a5d98eed35..1c0e2db2ce7 100644 --- a/src/pybind/mgr/volumes/fs/volume.py +++ b/src/pybind/mgr/volumes/fs/volume.py @@ -261,13 +261,7 @@ class VolumeClient(object): '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: @@ -324,6 +318,12 @@ class VolumeClient(object): 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 @@ -342,7 +342,7 @@ class VolumeClient(object): # 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: