]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: validate fsid during ceph-volume command
authorMichael Fritch <mfritch@suse.com>
Tue, 27 Jul 2021 21:56:25 +0000 (15:56 -0600)
committerSebastian Wagner <sewagner@redhat.com>
Tue, 10 Aug 2021 14:32:16 +0000 (16:32 +0200)
Signed-off-by: Michael Fritch <mfritch@suse.com>
(cherry picked from commit f0609429c05a70b6e6e7f131f56468e704be9640)

src/cephadm/cephadm
src/cephadm/tests/test_cephadm.py

index 5f0fa84eb56dcb246d31ae12a1ce5e8211360173..bf67d34eacc5f9dc65d6ae30a6ab6a3868665c83 100755 (executable)
@@ -4604,6 +4604,7 @@ def command_enter(ctx):
 
 @infer_fsid
 @infer_image
+@validate_fsid
 def command_ceph_volume(ctx):
     # type: (CephadmContext) -> None
     cp = read_config(ctx.config)
index 6993214ac072b30f0cf4590f47ba110d9fb03bbd..d6bf394fc2a199b08700cc8158f3b091ff2c371d 100644 (file)
@@ -1525,6 +1525,14 @@ class TestCephVolume(object):
             cd.command_ceph_volume(ctx)
             assert ctx.fsid == fsid
 
+        cmd = self._get_cmd('--fsid', '00000000-0000-0000-0000-0000deadbeez')
+        with with_cephadm_ctx(cmd) as ctx:
+            err = 'not an fsid'
+            with pytest.raises(cd.Error, match=err):
+                retval = cd.command_shell(ctx)
+                assert retval == 1
+                assert ctx.fsid == None
+
         s = get_ceph_conf(fsid=fsid)
         f = cephadm_fs.create_file('ceph.conf', contents=s)