]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rbd: fix no lockers are obtained, ImageNotFound exception will be output 34388/head
authorzhangdaolong <root@localhost.localdomain>
Tue, 24 Mar 2020 00:51:44 +0000 (08:51 +0800)
committerNathan Cutler <ncutler@suse.com>
Wed, 15 Apr 2020 20:37:24 +0000 (22:37 +0200)
No lockers are obtained, ImageNotFound exception will be output,
but tht image is always exist.when lockers number is zero,
Should not output any exceptions。

Fixes: https://tracker.ceph.com/issues/44613
Signed-off-by: zhangdaolong <zhangdaolong@fiberhome.com>
(cherry picked from commit a183aac978dac69f996250324975073a78cb476b)

src/pybind/rbd/rbd.pyx
src/test/pybind/test_rbd.py

index f7685d60e06c9d103d4ce2b069e3f9a0ea333467..a389a3d10cea01e299c45a37b5bc16d62765b0c6 100644 (file)
@@ -4721,6 +4721,9 @@ cdef class LockOwnerIterator(object):
                                           &self.num_lock_owners)
             if ret >= 0:
                 break
+            elif ret == -errno.ENOENT:
+                self.num_lock_owners = 0
+                break
             elif ret != -errno.ERANGE:
                 raise make_ex(ret, 'error listing lock owners for image %s' % image.name)
 
index 214266515fe4c0c906e3f0682fcc08a23f4bd411..a353075e9a9d4f01e07f471ed933368ccc066fa4 100644 (file)
@@ -1728,10 +1728,13 @@ class TestExclusiveLock(object):
                 rados2.conf_set('rbd_blacklist_on_break_lock', 'true')
                 with Image(ioctx2, image_name) as image, \
                      Image(blacklist_ioctx, image_name) as blacklist_image:
+
+                    lock_owners = list(image.lock_get_owners())
+                    eq(0, len(lock_owners))
+
                     blacklist_image.lock_acquire(RBD_LOCK_MODE_EXCLUSIVE)
                     assert_raises(ReadOnlyImage, image.lock_acquire,
                                   RBD_LOCK_MODE_EXCLUSIVE)
-
                     lock_owners = list(image.lock_get_owners())
                     eq(1, len(lock_owners))
                     eq(RBD_LOCK_MODE_EXCLUSIVE, lock_owners[0]['mode'])