Skip to content
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

Merged
merged 3 commits into from Oct 1, 2019

Conversation

joscollin
Copy link
Member

@joscollin joscollin added bug-fix cephfs Ceph File System labels Sep 16, 2019
Copy link
Member

@batrick batrick left a 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.

@joscollin
Copy link
Member Author

Needs a test otherwise LGTM.

It was a quick WIP in between my other tasks. I will update the PR today. Thanks.

@joscollin joscollin changed the title [wip] mgr/volumes: protection for fs volume rm command mgr/volumes: protection for fs volume rm command Sep 17, 2019
@joscollin
Copy link
Member Author

@batrick Bugs found are fixed and Updated the tests. Please review again.

@joscollin
Copy link
Member Author

http://pulpito.front.sepia.ceph.com/jcollin-2019-09-18_00:16:09-fs-wip-B41841-yes-really-mean-it-distro-basic-smithi/

The tests are passed, but I don't see the _delete_test_volume execution in the passed tests^.

@joscollin joscollin force-pushed the wip-B41841-yes-really-mean-it branch 2 times, most recently from 772b982 to 59ceac8 Compare September 20, 2019 09:37
src/pybind/mgr/volumes/fs/volume.py Outdated Show resolved Hide resolved
qa/tasks/cephfs/test_volumes.py Outdated Show resolved Hide resolved
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}
Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

@jtlayton jtlayton Sep 23, 2019

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".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtlayton Fixed now.

@joscollin joscollin force-pushed the wip-B41841-yes-really-mean-it branch 2 times, most recently from 52c6372 to e982223 Compare September 24, 2019 12:40
@joscollin
Copy link
Member Author

joscollin commented Sep 25, 2019

http://pulpito.front.sepia.ceph.com/jcollin-2019-09-24_17:28:16-fs-wip-B41841-yes-really-mean-it-distro-basic-smithi/

This test fail because fs volume rm doesn't give a CommandFailedError even if we try to remove the non-existent volume. fs volume rm always returns success. We shouldn't modify the fs volume rm code in favour of the test code. So I think I will skip the removal confirming part in test_volume_rm (check if it's gone). @batrick What do you suggest?

@@ -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 ',
Copy link
Contributor

@ajarr ajarr Sep 26, 2019

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.

Copy link
Contributor

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>}

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 " \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/and/that/


#check if it's gone
try:
self._fs_cmd("volume", "rm", self.volname, "--yes-i-really-mean-it")
Copy link
Contributor

@ajarr ajarr Sep 26, 2019

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

@ajarr
Copy link
Contributor

ajarr commented Sep 26, 2019

http://pulpito.front.sepia.ceph.com/jcollin-2019-09-24_17:28:16-fs-wip-B41841-yes-really-mean-it-distro-basic-smithi/

This test fail because fs volume rm doesn't give a CommandFailedError even if we try to remove the non-existent volume. fs volume rm always returns success. We shouldn't modify the fs volume rm code in favour of the test code. So I think I will skip the removal confirming part in test_volume_rm (check if it's gone). @batrick What do you suggest?

I've suggested a better way to check whether a volume exists. Also, we'd want the fs volume rm to fail if the volume doesn't exist so that the command behaves similarly to fs suvolumegroup rm and fs subvolume rm. This can be in a different PR.

@joscollin
Copy link
Member Author

Also, we'd want the fs volume rm to fail if the volume doesn't exist so that the command behaves similarly to fs suvolumegroup rm and fs subvolume rm. This can be in a different PR.

I think I will fix that in this PR itself, so that the test function works fine.

self._fs_cmd("volume", "rm", self.volname)
except CommandFailedError as ce:
if ce.exitstatus != errno.EPERM:
raise
Copy link
Contributor

@ajarr ajarr Sep 26, 2019

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

@joscollin joscollin force-pushed the wip-B41841-yes-really-mean-it branch 3 times, most recently from 3ccaee7 to 7844a5e Compare September 27, 2019 04:14
@joscollin
Copy link
Member Author

@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.

try:
self._fs_cmd("volume", "rm", self.volname, "--yes-i-really-mean-it")
except CommandFailedError as ce:
#re-raise EPERM
Copy link
Contributor

@ajarr ajarr Sep 27, 2019

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.

Copy link
Member Author

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

Copy link
Contributor

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.

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, " \
Copy link
Contributor

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?

Copy link
Member Author

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.

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."
Copy link
Contributor

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.

@joscollin
Copy link
Member Author

@ajarr Fixed

Copy link
Contributor

@ajarr ajarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ajarr ajarr requested a review from batrick September 30, 2019 11:17
@ajarr
Copy link
Contributor

ajarr commented Sep 30, 2019

http://pulpito.front.sepia.ceph.com/jcollin-2019-09-27_15:47:30-fs-wip-B41841-yes-really-mean-it-distro-basic-smithi/

Jos, are you able to access this link? I can't. Did the tests pass?

@joscollin
Copy link
Member Author

http://pulpito.front.sepia.ceph.com/jcollin-2019-09-27_15:47:30-fs-wip-B41841-yes-really-mean-it-distro-basic-smithi/

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.

jcollin@teuthology:/a$ cd /a/jcollin-2019-09-27_15\:47\:30-fs-wip-B41841-yes-really-mean-it-distro-basic-smithi/
jcollin@teuthology:/a/jcollin-2019-09-27_15:47:30-fs-wip-B41841-yes-really-mean-it-distro-basic-smithi$ ls
4339473  4339474  coverage.log  results.log

Those^ are the jobs.

@ajarr ajarr dismissed batrick’s stale review October 1, 2019 07:33

The comments have been resolved.

@ajarr ajarr merged commit 0bfcace into ceph:master Oct 1, 2019
@joscollin joscollin deleted the wip-B41841-yes-really-mean-it branch October 1, 2019 08:19
@smithfarm smithfarm changed the title mgr/volumes: protection for fs volume rm command mgr/volumes: protection for "fs volume rm" command Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants