]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: allow bootstrap to populate remote image id
authorJason Dillaman <dillaman@redhat.com>
Mon, 6 Jan 2020 20:22:52 +0000 (15:22 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 9 Jan 2020 15:48:52 +0000 (10:48 -0500)
The remote image id is used as a sanity check and a test for
permanently shutting down the replayer after the remote image is
deleted. Recent refactor work broke this by passing the remote
image id by value.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/rbd_mirror/image_replayer/test_mock_BootstrapRequest.cc
src/test/rbd_mirror/test_mock_ImageReplayer.cc
src/tools/rbd_mirror/ImageReplayer.cc
src/tools/rbd_mirror/image_replayer/BootstrapRequest.cc
src/tools/rbd_mirror/image_replayer/BootstrapRequest.h

index 1f7072edb82dd21d2a0a564135857239b5a4da90..1fd4192c2f37a9eab006b885dbe03b7d87e8fb57 100644 (file)
@@ -567,7 +567,6 @@ public:
 
   MockBootstrapRequest *create_request(MockThreads* mock_threads,
                                        MockInstanceWatcher *mock_instance_watcher,
-                                       const std::string &remote_image_id,
                                        const std::string &global_image_id,
                                        const std::string &local_mirror_uuid,
                                        Context *on_finish) {
@@ -575,12 +574,12 @@ public:
                                     m_local_io_ctx,
                                     m_remote_io_ctx,
                                     mock_instance_watcher,
-                                    remote_image_id,
                                     global_image_id,
                                     local_mirror_uuid,
                                     nullptr, nullptr,
                                     &m_local_test_image_ctx,
                                     &m_local_image_id,
+                                    &m_remote_image_id,
                                     &m_remote_mirror_uuid,
                                     &m_mock_remote_journaler,
                                     &m_do_resync, on_finish);
@@ -591,6 +590,7 @@ public:
 
   librbd::MockTestImageCtx *m_local_test_image_ctx = nullptr;
   std::string m_local_image_id;
+  std::string m_remote_image_id;
   std::string m_remote_mirror_uuid;
   ::journal::MockJournaler *m_mock_remote_journaler = nullptr;
   bool m_do_resync = false;
@@ -648,8 +648,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, Success) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -703,8 +703,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, OpenLocalImageError) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(-EINVAL, ctx.wait());
 }
@@ -771,8 +771,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, OpenLocalImageDNE) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -826,8 +826,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, OpenLocalImagePrimary) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(-EREMOTEIO, ctx.wait());
 }
@@ -876,8 +876,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, CreateLocalImageError) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(-EINVAL, ctx.wait());
 }
@@ -937,8 +937,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, PrepareReplayError) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(-EINVAL, ctx.wait());
 }
@@ -995,8 +995,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, PrepareReplayResyncRequested) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(0, ctx.wait());
   ASSERT_TRUE(m_do_resync);
@@ -1058,8 +1058,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, PrepareReplaySyncing) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -1116,8 +1116,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, PrepareReplayDisconnected) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(0, ctx.wait());
 }
@@ -1178,8 +1178,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, ImageSyncError) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(-EINVAL, ctx.wait());
 }
@@ -1236,8 +1236,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, ImageSyncCanceled) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->cancel();
   request->send();
   ASSERT_EQ(-ECANCELED, ctx.wait());
@@ -1298,8 +1298,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, CloseLocalImageError) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(-EREMOTEIO, ctx.wait());
 }
@@ -1355,8 +1355,8 @@ TEST_F(TestMockImageReplayerBootstrapRequest, CloseRemoteImageError) {
   MockThreads mock_threads(m_threads);
   MockInstanceWatcher mock_instance_watcher;
   MockBootstrapRequest *request = create_request(
-    &mock_threads, &mock_instance_watcher, mock_remote_image_ctx.id,
-    "global image id", "local mirror uuid", &ctx);
+    &mock_threads, &mock_instance_watcher, "global image id",
+    "local mirror uuid", &ctx);
   request->send();
   ASSERT_EQ(0, ctx.wait());
 }
index 01bf2e499c25f22e65b0e8b39ba4d9ed4695f65f..fb30f3b113b2aaa417b2540b1af5f718b187d9c7 100644 (file)
@@ -113,13 +113,13 @@ struct BootstrapRequest<librbd::MockTestImageCtx> {
       librados::IoCtx &local_io_ctx,
       librados::IoCtx &remote_io_ctx,
       rbd::mirror::InstanceWatcher<librbd::MockTestImageCtx> *instance_watcher,
-      const std::string &remote_image_id,
       const std::string &global_image_id,
       const std::string &local_mirror_uuid,
       ::journal::CacheManagerHandler *cache_manager_handler,
       rbd::mirror::ProgressContext *progress_ctx,
       librbd::MockTestImageCtx **local_image_ctx,
       std::string* local_image_id,
+      std::string* remote_image_id,
       std::string* remote_mirror_uuid,
       ::journal::MockJournalerProxy** remote_journaler,
       bool *do_resync, Context *on_finish) {
index e993e55507db7bdaa62c601e120b06303d1b18cc..766191c040e39bb8f836a4f52a27d00dc466413d 100644 (file)
@@ -352,10 +352,10 @@ void ImageReplayer<I>::bootstrap() {
       ImageReplayer, &ImageReplayer<I>::handle_bootstrap>(this);
   auto request = image_replayer::BootstrapRequest<I>::create(
       m_threads, m_local_io_ctx, m_remote_image.io_ctx, m_instance_watcher,
-      m_remote_image.image_id, m_global_image_id, m_local_mirror_uuid,
-      m_cache_manager_handler, &m_progress_cxt, &m_local_image_ctx,
-      &m_local_image_id, &m_remote_image.mirror_uuid, &m_remote_journaler,
-      &m_resync_requested, ctx);
+      m_global_image_id, m_local_mirror_uuid, m_cache_manager_handler,
+      &m_progress_cxt, &m_local_image_ctx, &m_local_image_id,
+      &m_remote_image.image_id, &m_remote_image.mirror_uuid,
+      &m_remote_journaler, &m_resync_requested, ctx);
 
   request->get();
   m_bootstrap_request = request;
index cdc6a95aac67307d9d7ddecc3af45cc1a691650e..379cb666c51670a553b7e543947f587514b783f1 100644 (file)
@@ -49,13 +49,13 @@ BootstrapRequest<I>::BootstrapRequest(
     librados::IoCtx& local_io_ctx,
     librados::IoCtx& remote_io_ctx,
     InstanceWatcher<I>* instance_watcher,
-    const std::string& remote_image_id,
     const std::string& global_image_id,
     const std::string& local_mirror_uuid,
     ::journal::CacheManagerHandler* cache_manager_handler,
     ProgressContext* progress_ctx,
     I** local_image_ctx,
     std::string* local_image_id,
+    std::string* remote_image_id,
     std::string* remote_mirror_uuid,
     Journaler** remote_journaler,
     bool* do_resync,
@@ -66,13 +66,13 @@ BootstrapRequest<I>::BootstrapRequest(
     m_local_io_ctx(local_io_ctx),
     m_remote_io_ctx(remote_io_ctx),
     m_instance_watcher(instance_watcher),
-    m_remote_image_id(remote_image_id),
     m_global_image_id(global_image_id),
     m_local_mirror_uuid(local_mirror_uuid),
     m_cache_manager_handler(cache_manager_handler),
     m_progress_ctx(progress_ctx),
     m_local_image_ctx(local_image_ctx),
     m_local_image_id(local_image_id),
+    m_remote_image_id(remote_image_id),
     m_remote_mirror_uuid(remote_mirror_uuid),
     m_remote_journaler(remote_journaler),
     m_do_resync(do_resync),
@@ -173,7 +173,7 @@ void BootstrapRequest<I>::prepare_remote_image() {
   auto req = image_replayer::PrepareRemoteImageRequest<I>::create(
     m_threads, m_remote_io_ctx, m_global_image_id, m_local_mirror_uuid,
     *m_local_image_id, journal_settings, m_cache_manager_handler,
-    m_remote_mirror_uuid, &m_remote_image_id, m_remote_journaler,
+    m_remote_mirror_uuid, m_remote_image_id, m_remote_journaler,
     &m_client_state, &m_client_meta, ctx);
   req->send();
 }
@@ -191,7 +191,7 @@ void BootstrapRequest<I>::handle_prepare_remote_image(int r) {
     dout(10) << "remote image does not exist" << dendl;
 
     // TODO need to support multiple remote images
-    if (m_remote_image_id.empty() && !m_local_image_id->empty() &&
+    if (m_remote_image_id->empty() && !m_local_image_id->empty() &&
         m_local_image_tag_owner == *m_remote_mirror_uuid) {
       // local image exists and is non-primary and linked to the missing
       // remote image
@@ -219,7 +219,7 @@ void BootstrapRequest<I>::handle_prepare_remote_image(int r) {
 
 template <typename I>
 void BootstrapRequest<I>::open_remote_image() {
-  dout(15) << "remote_image_id=" << m_remote_image_id << dendl;
+  dout(15) << "remote_image_id=" << *m_remote_image_id << dendl;
 
   update_progress("OPEN_REMOTE_IMAGE");
 
@@ -227,7 +227,7 @@ void BootstrapRequest<I>::open_remote_image() {
     BootstrapRequest<I>, &BootstrapRequest<I>::handle_open_remote_image>(
       this);
   OpenImageRequest<I> *request = OpenImageRequest<I>::create(
-    m_remote_io_ctx, &m_remote_image_ctx, m_remote_image_id, false,
+    m_remote_io_ctx, &m_remote_image_ctx, *m_remote_image_id, false,
     ctx);
   request->send();
 }
index 33adc7bdee3196c1f8c594e103d4ad74c521e1fa..012bbbe2141b8842c882d5f5324bd7f0523232ad 100644 (file)
@@ -48,21 +48,21 @@ public:
       librados::IoCtx& local_io_ctx,
       librados::IoCtx& remote_io_ctx,
       InstanceWatcher<ImageCtxT>* instance_watcher,
-      const std::string& remote_image_id,
       const std::string& global_image_id,
       const std::string& local_mirror_uuid,
       ::journal::CacheManagerHandler* cache_manager_handler,
       ProgressContext* progress_ctx,
       ImageCtxT** local_image_ctx,
       std::string* local_image_id,
+      std::string* remote_image_id,
       std::string* remote_mirror_uuid,
       Journaler** remote_journaler,
       bool* do_resync,
       Context* on_finish) {
     return new BootstrapRequest(
-      threads, local_io_ctx, remote_io_ctx, instance_watcher, remote_image_id,
-      global_image_id, local_mirror_uuid,  cache_manager_handler, progress_ctx,
-      local_image_ctx, local_image_id, remote_mirror_uuid, remote_journaler,
+      threads, local_io_ctx, remote_io_ctx, instance_watcher, global_image_id,
+      local_mirror_uuid,  cache_manager_handler, progress_ctx, local_image_ctx,
+      local_image_id, remote_image_id, remote_mirror_uuid, remote_journaler,
       do_resync, on_finish);
   }
 
@@ -71,13 +71,13 @@ public:
       librados::IoCtx& local_io_ctx,
       librados::IoCtx& remote_io_ctx,
       InstanceWatcher<ImageCtxT>* instance_watcher,
-      const std::string& remote_image_id,
       const std::string& global_image_id,
       const std::string& local_mirror_uuid,
       ::journal::CacheManagerHandler* cache_manager_handler,
       ProgressContext* progress_ctx,
       ImageCtxT** local_image_ctx,
       std::string* local_image_id,
+      std::string* remote_image_id,
       std::string* remote_mirror_uuid,
       Journaler** remote_journaler,
       bool* do_resync,
@@ -144,13 +144,13 @@ private:
   librados::IoCtx &m_local_io_ctx;
   librados::IoCtx &m_remote_io_ctx;
   InstanceWatcher<ImageCtxT> *m_instance_watcher;
-  std::string m_remote_image_id;
   std::string m_global_image_id;
   std::string m_local_mirror_uuid;
   ::journal::CacheManagerHandler *m_cache_manager_handler;
   ProgressContext *m_progress_ctx;
   ImageCtxT **m_local_image_ctx;
   std::string* m_local_image_id;
+  std::string* m_remote_image_id;
   std::string* m_remote_mirror_uuid;
   Journaler** m_remote_journaler;
   bool *m_do_resync;