New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgr/volumes: protection for "fs volume rm" command #30407
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a test otherwise LGTM.
It was a quick WIP in between my other tasks. I will update the PR today. Thanks. |
a7f7601
to
6f7cc09
Compare
fs volume rm
commandfs volume rm
command
@batrick Bugs found are fixed and Updated the tests. Please review again. |
The tests are passed, but I don't see the |
772b982
to
59ceac8
Compare
src/pybind/mgr/volumes/fs/volume.py
Outdated
if confirm is not None and confirm == "--yes-i-really-mean-it": | ||
command = {'prefix': 'fs rm', 'fs_name': fs_name, 'yes_i_really_mean_it': True} | ||
else: | ||
command = {'prefix': 'fs rm', 'fs_name': fs_name, 'yes_i_really_mean_it': False} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it correct to check the --yes-i-really-mean-it flag after the previous 'fs fail' mon command? It seems like you might want to check for confirmation before making any changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think that's better. Do you mean before the command = {'prefix': 'fs fail', 'fs_name': fs_name}
line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. That means you'll want to do a separate check for it and bail out early instead of just passing the right value to "fs rm".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jtlayton Fixed now.
52c6372
to
e982223
Compare
This test fail because |
src/pybind/mgr/volumes/module.py
Outdated
@@ -37,7 +37,8 @@ class Module(orchestrator.OrchestratorClientMixin, MgrModule): | |||
}, | |||
{ | |||
'cmd': 'fs volume rm ' | |||
'name=vol_name,type=CephString', | |||
'name=vol_name,type=CephString ' | |||
'name=yes_i_really_mean_it,type=CephString,req=false ', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I see when I check the help,
$ ceph fs volume rm --help
fs volume rm <vol_name> {<yes_i_really_mean_it>} Delete a CephFS volume
It's not obvious to me that I've to pass --yes-i-really-mean-it to delete the fs volume. Please include that in the desc
below. e.g.,
Delete a FS volume by passing --yes-i-really-mean-it
flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And prefer that you change the option name to yes-i-really-mean it
. This way the help would look like,
fs volume rm <vol_name> {<yes-i-really-mean-it>}
src/pybind/mgr/volumes/fs/volume.py
Outdated
def remove_filesystem(self, fs_name): | ||
def remove_filesystem(self, fs_name, confirm): | ||
if confirm != "--yes-i-really-mean-it": | ||
return -errno.EPERM, "", "this is a DESTRUCTIVE operation and will make " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/and/that/
qa/tasks/cephfs/test_volumes.py
Outdated
|
||
#check if it's gone | ||
try: | ||
self._fs_cmd("volume", "rm", self.volname, "--yes-i-really-mean-it") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check whether volume exists you can do this, https://github.com/ceph/ceph/blob/master/qa/tasks/cephfs/filesystem.py#L601
I've suggested a better way to check whether a volume exists. Also, we'd want the |
I think I will fix that in this PR itself, so that the test function works fine. |
qa/tasks/cephfs/test_volumes.py
Outdated
self._fs_cmd("volume", "rm", self.volname) | ||
except CommandFailedError as ce: | ||
if ce.exitstatus != errno.EPERM: | ||
raise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please raise with a useful message, something like, we expected the fs volume rm
command to fail with EPERM
3ccaee7
to
7844a5e
Compare
@ajarr Fixed all the comments from #30407 (review) till the end, as discussed yesterday. Please verify them. The teuthology tests are running. I will post it when passed. |
qa/tasks/cephfs/test_volumes.py
Outdated
try: | ||
self._fs_cmd("volume", "rm", self.volname, "--yes-i-really-mean-it") | ||
except CommandFailedError as ce: | ||
#re-raise EPERM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need a try catch
block here? You're just re-raising the exception You're not handling the exception in any special way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We expect the volume rm <self.volname> --yes-i-really-mean-it
to succeed here. If it succeeds we don't re-raise. But if it fails, then it should mostly be a permission issue. May be I could give a check if ce.exitstatus == errno.EPERM
then raise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a try catch
block here. If the command fails, let it fail.
qa/tasks/cephfs/test_volumes.py
Outdated
self._fs_cmd("volume", "rm", self.volname) | ||
except CommandFailedError as ce: | ||
if ce.exitstatus != errno.EPERM: | ||
raise RuntimeError("expected the 'fs volume rm' command to fail with EPERM, " \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need a \
to break a long line when you're enclosing the string within brackets and using quotes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I will update it.
src/pybind/mgr/volumes/fs/volume.py
Outdated
if confirm != "--yes-i-really-mean-it": | ||
return -errno.EPERM, "", "this is a DESTRUCTIVE operation that will make " \ | ||
"data in your filesystem permanently inaccessible. " \ | ||
"Add --yes-i-really-mean-it if you are sure you wish to continue." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't find this instruction clear. Add '--yes-i-really-meant' where? The user has to re-issue the command and append the flag, right?
e.g.,
See the stderr message when you try to delete a RADOS pool.
$ ceph osd pool delete cephfs.a.data
Error EPERM: WARNING: this will *PERMANENTLY DESTROY* all data stored in pool cephfs.a.data. If you are *ABSOLUTELY CERTAIN* that is what you want, pass the pool name *twice*, followed by --yes-i-really-really-mean-it.
So maybe something like,
Error EPERM: WARNING: this will *PERMANENTLY DESTROY* all data stored in the filesystem <fs-name>. If you are *ABSOLUTELY CERTAIN* that is what you want, re-issue the command followed by --yes-i-really-mean-it.
Fixes: https://tracker.ceph.com/issues/41841 Signed-off-by: Jos Collin <jcollin@redhat.com>
Fixes: https://tracker.ceph.com/issues/41841 Signed-off-by: Jos Collin <jcollin@redhat.com>
Fixes: ceph#30381 (comment) Signed-off-by: Jos Collin <jcollin@redhat.com>
7844a5e
to
a58a6cd
Compare
@ajarr Fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Jos, are you able to access this link? I can't. Did the tests pass? |
The tests are passed. Please check teuthology if you are not able to access the url.
Those^ are the jobs. |
fs volume rm
command
Fixes: https://tracker.ceph.com/issues/41841