]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: complete pool watcher initialization if object missing
authorJason Dillaman <dillaman@redhat.com>
Fri, 22 Feb 2019 15:59:26 +0000 (10:59 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 16 May 2019 13:28:59 +0000 (09:28 -0400)
If the mirroring object is missing, complete the initialization and
continue to retry in the background. This is useful for cases where
the remote doesn't (yet) have mirroring enabled but the remote
pool watcher initialization is delaying the leader watcher promotion
to the point where the leader is blacklisted by its peers.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 80954cd914c86e11ffb6a8cbfcb21202cb8131b5)

src/test/rbd_mirror/test_mock_PoolWatcher.cc
src/tools/rbd_mirror/PoolReplayer.cc
src/tools/rbd_mirror/PoolWatcher.cc

index 07f9a4d62f8a4ea7b81d7a87e7bbd177e4550740..6e8b67908a8faa8b75be778597e558703c4f9326 100644 (file)
@@ -498,7 +498,7 @@ TEST_F(TestMockPoolWatcher, RegisterWatcherMissing) {
                                     mock_listener);
   C_SaferCond ctx;
   mock_pool_watcher.init(&ctx);
-  ASSERT_EQ(0, ctx.wait());
+  ASSERT_EQ(-ENOENT, ctx.wait());
 
   ASSERT_TRUE(wait_for_update(1));
   expect_mirroring_watcher_unregister(mock_mirroring_watcher, 0);
index ea28a27c70c767e5b2942ef61f951a220ed50bf8..049461e890c5adaca127db33c3e97153602cf84d 100644 (file)
@@ -818,7 +818,13 @@ template <typename I>
 void PoolReplayer<I>::handle_init_remote_pool_watcher(
     int r, Context *on_finish) {
   dout(10) << "r=" << r << dendl;
-  if (r < 0) {
+  if (r == -ENOENT) {
+    // Technically nothing to do since the other side doesn't
+    // have mirroring enabled. Eventually the remote pool watcher will
+    // detect images (if mirroring is enabled), so no point propagating
+    // an error which would just busy-spin the state machines.
+    dout(0) << "remote peer does not have mirroring configured" << dendl;
+  } else if (r < 0) {
     derr << "failed to retrieve remote images: " << cpp_strerror(r) << dendl;
     on_finish = new FunctionContext([this, on_finish, r](int) {
         on_finish->complete(r);
index 9056a615ddd600f6ade263488a03537ddec396a8..d73c59d389572852da2ac9ecb7ccbeaa9e9c2746 100644 (file)
@@ -174,6 +174,9 @@ void PoolWatcher<I>::handle_register_watcher(int r) {
   } else if (r == -ENOENT) {
     dout(5) << "mirroring directory does not exist" << dendl;
     schedule_refresh_images(30);
+
+    Mutex::Locker locker(m_lock);
+    std::swap(on_init_finish, m_on_init_finish);
   } else {
     derr << "unexpected error registering mirroring directory watch: "
          << cpp_strerror(r) << dendl;