]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/pybind/snap_schedule: do not fail when no fs snapshot schedules are available
authorSébastien Han <seb@redhat.com>
Tue, 16 Mar 2021 17:04:06 +0000 (18:04 +0100)
committerSébastien Han <seb@redhat.com>
Mon, 26 Apr 2021 06:57:28 +0000 (08:57 +0200)
When listing for available snapshot schedules, we should not an error in case
there is none. We should just return 0 with an empty dict.

Fixes: https://tracker.ceph.com/issues/49837
Signed-off-by: Sébastien Han <seb@redhat.com>
qa/tasks/cephfs/test_snap_schedules.py
src/pybind/mgr/snap_schedule/module.py

index 789a082af10a4b4285cb3fc44b96fd966ffab457..db3c402bc1805cd7cff1c34a895d1770c7d767d5 100644 (file)
@@ -173,7 +173,7 @@ class TestSnapSchedules(CephFSTestCase):
     def test_non_existent_snap_schedule_list(self):
         """Test listing snap schedules on a non-existing filesystem path failure"""
         try:
-            self.fs_snap_schedule_cmd('list', f'path={TestSnapSchedules.TEST_DIRECTORY}', 'format=json')
+            self.fs_snap_schedule_cmd('list', f'path={TestSnapSchedules.TEST_DIRECTORY}')
         except CommandFailedError as ce:
             if ce.exitstatus != errno.ENOENT:
                 raise RuntimeError('incorrect errno when listing a non-existing snap schedule')
@@ -185,7 +185,7 @@ class TestSnapSchedules(CephFSTestCase):
         self.mount_a.run_shell(['mkdir', '-p', TestSnapSchedules.TEST_DIRECTORY])
 
         try:
-            self.fs_snap_schedule_cmd('list', f'path={TestSnapSchedules.TEST_DIRECTORY}', 'format=json')
+            self.fs_snap_schedule_cmd('list', f'path={TestSnapSchedules.TEST_DIRECTORY}')
         except CommandFailedError as ce:
             if ce.exitstatus != errno.ENOENT:
                 raise RuntimeError('incorrect errno when listing a non-existing snap schedule')
@@ -203,7 +203,7 @@ class TestSnapSchedules(CephFSTestCase):
         self.fs_snap_schedule_cmd('remove', f'path={TestSnapSchedules.TEST_DIRECTORY}')
 
         try:
-            self.fs_snap_schedule_cmd('list', f'path={TestSnapSchedules.TEST_DIRECTORY}', 'format=json')
+            self.fs_snap_schedule_cmd('list', f'path={TestSnapSchedules.TEST_DIRECTORY}')
         except CommandFailedError as ce:
             if ce.exitstatus != errno.ENOENT:
                 raise RuntimeError('incorrect errno when listing a non-existing snap schedule')
index 84b04c4bb7a2b89ba6b0605734fbdc000b143434..ec4b30513cc17ba52976a4a9d529f432ce4ea155 100644 (file)
@@ -100,6 +100,9 @@ class Module(MgrModule):
         except CephfsConnectionException as e:
             return e.to_tuple()
         if not scheds:
+            if format == 'json':
+                output: Dict[str, str] = {}
+                return 0, json.dumps(output), ''
             return -errno.ENOENT, '', f'SnapSchedule for {path} not found'
         if format == 'json':
             # json_list = ','.join([sched.json_list() for sched in scheds])