mirror of
https://github.com/ceph/ceph
synced 2025-02-23 11:07:35 +00:00
mgr/volumes: protection for 'fs volume rm' command
Fixes: https://tracker.ceph.com/issues/41841 Signed-off-by: Jos Collin <jcollin@redhat.com>
This commit is contained in:
parent
b2ca51a8bf
commit
59cf9beb31
@ -230,11 +230,18 @@ class VolumeClient(object):
|
||||
'data': data_pool}
|
||||
return self.mgr.mon_command(command)
|
||||
|
||||
def remove_filesystem(self, fs_name):
|
||||
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)
|
||||
|
||||
command = {'prefix': 'fs fail', 'fs_name': fs_name}
|
||||
r, outb, outs = self.mgr.mon_command(command)
|
||||
if r != 0:
|
||||
return r, outb, outs
|
||||
|
||||
command = {'prefix': 'fs rm', 'fs_name': fs_name, 'yes_i_really_mean_it': True}
|
||||
return self.mgr.mon_command(command)
|
||||
|
||||
@ -275,7 +282,7 @@ class VolumeClient(object):
|
||||
# create mds
|
||||
return self.create_mds(volname)
|
||||
|
||||
def delete_volume(self, volname):
|
||||
def delete_volume(self, volname, confirm):
|
||||
"""
|
||||
delete the given module (tear down mds, remove filesystem)
|
||||
"""
|
||||
@ -297,11 +304,13 @@ 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)
|
||||
r, outb, outs = self.remove_filesystem(volname, confirm)
|
||||
if r != 0:
|
||||
return r, outb, outs
|
||||
else:
|
||||
log.warning("Filesystem already gone for volume '{0}'".format(volname))
|
||||
err = "Filesystem not found for volume '{0}'".format(volname)
|
||||
log.warning(err)
|
||||
return -errno.ENOENT, "", err
|
||||
metadata_pool, data_pool = self.gen_pool_names(volname)
|
||||
r, outb, outs = self.remove_pool(metadata_pool)
|
||||
if r != 0:
|
||||
|
@ -37,8 +37,9 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
|
||||
},
|
||||
{
|
||||
'cmd': 'fs volume rm '
|
||||
'name=vol_name,type=CephString',
|
||||
'desc': "Delete a CephFS volume",
|
||||
'name=vol_name,type=CephString '
|
||||
'name=yes-i-really-mean-it,type=CephString,req=false ',
|
||||
'desc': "Delete a FS volume by passing --yes-i-really-mean-it flag",
|
||||
'perm': 'rw'
|
||||
},
|
||||
{
|
||||
@ -194,7 +195,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule):
|
||||
|
||||
def _cmd_fs_volume_rm(self, inbuf, cmd):
|
||||
vol_name = cmd['vol_name']
|
||||
return self.vc.delete_volume(vol_name)
|
||||
confirm = cmd.get('yes-i-really-mean-it', None)
|
||||
return self.vc.delete_volume(vol_name, confirm)
|
||||
|
||||
def _cmd_fs_volume_ls(self, inbuf, cmd):
|
||||
return self.vc.list_volumes()
|
||||
|
Loading…
Reference in New Issue
Block a user