]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rbd: fix no lockers are obtained, ImageNotFound exception will be output 34387/head
authorzhangdaolong <root@localhost.localdomain>
Tue, 24 Mar 2020 00:51:44 +0000 (08:51 +0800)
committerNathan Cutler <ncutler@suse.com>
Fri, 3 Apr 2020 03:23:35 +0000 (05:23 +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 b71458b5cb9362364014efe29f31185214a22bca..468928d1d92a00b58d540a5fa01b1a017fdbcd60 100644 (file)
@@ -5393,6 +5393,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 1bd84e81f84ad45403d2308a08888c4cd2840883..3a487874c099479669ac21c0fadfa783a3d0ceeb 100644 (file)
@@ -1855,10 +1855,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'])