mgr/rbd_support: level_spec is optional for schedule list/status

Commit fea6fdff4c ("mgr/rbd_support: level_spec passed to some
commands is not optional") is wrong.  While it is true that a valid
level_spec is needed to create a LevelSpec instance, an empty string
is very much a valid level spec -- it signifies "all levels".

This wasn't caught because within Ceph these commands are wrapped by
rbd CLI which injects an empty string in get_level_spec_args().

Fixes: https://tracker.ceph.com/issues/54058
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Ilya Dryomov 2022-01-29 15:01:27 +01:00
parent 2f5faabf42
commit a5eef01e92
2 changed files with 10 additions and 4 deletions

View File

@ -1129,6 +1129,9 @@ test_trash_purge_schedule() {
rbd pool init rbd2
rbd namespace create rbd2/ns1
test "$(ceph rbd trash purge schedule list)" = "{}"
ceph rbd trash purge schedule status | fgrep '"scheduled": []'
expect_fail rbd trash purge schedule ls
test "$(rbd trash purge schedule ls -R --format json)" = "[]"
@ -1229,6 +1232,9 @@ test_mirror_snapshot_schedule() {
rbd mirror pool enable rbd2/ns1 image
rbd mirror pool peer add rbd2 cluster1
test "$(ceph rbd mirror snapshot schedule list)" = "{}"
ceph rbd mirror snapshot schedule status | fgrep '"scheduled_images": []'
expect_fail rbd mirror snapshot schedule ls
test "$(rbd mirror snapshot schedule ls -R --format json)" = "[]"

View File

@ -108,7 +108,7 @@ class Module(MgrModule):
@CLIReadCommand('rbd mirror snapshot schedule list')
@with_latest_osdmap
def mirror_snapshot_schedule_list(self,
level_spec: str) -> Tuple[int, str, str]:
level_spec: str = '') -> Tuple[int, str, str]:
"""
List rbd mirror snapshot schedule
"""
@ -118,7 +118,7 @@ class Module(MgrModule):
@CLIReadCommand('rbd mirror snapshot schedule status')
@with_latest_osdmap
def mirror_snapshot_schedule_status(self,
level_spec: str) -> Tuple[int, str, str]:
level_spec: str = '') -> Tuple[int, str, str]:
"""
Show rbd mirror snapshot schedule status
"""
@ -248,7 +248,7 @@ class Module(MgrModule):
@CLIReadCommand('rbd trash purge schedule list')
@with_latest_osdmap
def trash_purge_schedule_list(self,
level_spec: str) -> Tuple[int, str, str]:
level_spec: str = '') -> Tuple[int, str, str]:
"""
List rbd trash purge schedule
"""
@ -258,7 +258,7 @@ class Module(MgrModule):
@CLIReadCommand('rbd trash purge schedule status')
@with_latest_osdmap
def trash_purge_schedule_status(self,
level_spec: str) -> Tuple[int, str, str]:
level_spec: str = '') -> Tuple[int, str, str]:
"""
Show rbd trash purge schedule status
"""