]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/rbd_support: make type hits on aio_mirror_image_*() callbacks better 54053/head
authorIlya Dryomov <idryomov@gmail.com>
Thu, 12 Oct 2023 19:32:53 +0000 (21:32 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Tue, 17 Oct 2023 11:40:25 +0000 (13:40 +0200)
Make it clear that mirror mode, mirror info and snap ID can be None if
the respective operation fails.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit 01fff6a72a328459c1d153e5dc1de6a34e48a82f)

Conflicts:
src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py [ commit
  e4a16e261370 ("mgr/rbd_support: add type annotation") not in
  pacific ]

src/pybind/mgr/rbd_support/mirror_snapshot_schedule.py

index 2abf666663c770ccc58446640d266c394345dfad..42ecdbbe0cf309e733c4e673524a6bbb304bde66 100644 (file)
@@ -132,7 +132,7 @@ class CreateSnapshotRequests:
             "CreateSnapshotRequests.handle_get_mirror_mode {}/{}/{}: r={} mode={}".format(
                 pool_id, namespace, image_id, comp.get_return_value(), mode))
 
-        if comp.get_return_value() < 0:
+        if mode is None:
             if comp.get_return_value() != -errno.ENOENT:
                 self.log.error(
                     "error when getting mirror mode for {}/{}/{}: {}".format(
@@ -174,7 +174,7 @@ class CreateSnapshotRequests:
             "CreateSnapshotRequests.handle_get_mirror_info {}/{}/{}: r={} info={}".format(
                 pool_id, namespace, image_id, comp.get_return_value(), info))
 
-        if comp.get_return_value() < 0:
+        if info is None:
             if comp.get_return_value() != -errno.ENOENT:
                 self.log.error(
                     "error when getting mirror info for {}/{}/{}: {}".format(
@@ -218,8 +218,7 @@ class CreateSnapshotRequests:
             "CreateSnapshotRequests.handle_create_snapshot for {}/{}/{}: r={}, snap_id={}".format(
                 pool_id, namespace, image_id, comp.get_return_value(), snap_id))
 
-        if comp.get_return_value() < 0 and \
-           comp.get_return_value() != -errno.ENOENT:
+        if snap_id is None and comp.get_return_value() != -errno.ENOENT:
             self.log.error(
                 "error when creating snapshot for {}/{}/{}: {}".format(
                     pool_id, namespace, image_id, comp.get_return_value()))