]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd-mirror: implement group replayer Health State
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>
Fri, 28 Mar 2025 16:24:44 +0000 (21:54 +0530)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 28 Sep 2025 18:25:03 +0000 (20:25 +0200)
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
src/tools/rbd_mirror/GroupReplayer.cc
src/tools/rbd_mirror/GroupReplayer.h
src/tools/rbd_mirror/InstanceReplayer.cc
src/tools/rbd_mirror/group_replayer/Replayer.h
src/tools/rbd_mirror/group_replayer/Types.h [new file with mode: 0644]

index 8d597cf1a0db901020eaeec9fecfc20af42f95b0..fddc59fd8aabc5d477da7a086b47ef640decd26c 100644 (file)
@@ -292,9 +292,16 @@ void GroupReplayer<I>::sync_group_names() {
 }
 
 template <typename I>
-image_replayer::HealthState GroupReplayer<I>::get_health_state() const {
-  // TODO: Implement something like m_mirror_image_status_state for group
-  return image_replayer::HEALTH_STATE_OK;
+group_replayer::HealthState GroupReplayer<I>::get_health_state() const {
+  std::lock_guard locker{m_lock};
+
+  if (!m_status_state) {
+    return group_replayer::HEALTH_STATE_OK;
+  } else if (*m_status_state ==
+               cls::rbd::MIRROR_GROUP_STATUS_STATE_UNKNOWN) {
+    return group_replayer::HEALTH_STATE_WARNING;
+  }
+  return group_replayer::HEALTH_STATE_ERROR;
 }
 
 template <typename I>
@@ -868,7 +875,7 @@ void GroupReplayer<I>::shut_down(int r) {
   // chain the shut down sequence (reverse order)
   Context *ctx = new LambdaContext(
     [this, r](int _r) {
-      set_mirror_group_status_update(m_status_state, m_state_desc);
+      set_mirror_group_status_update(*m_status_state, m_state_desc);
       handle_shut_down(r);
     });
 
@@ -1123,6 +1130,8 @@ void GroupReplayer<I>::set_mirror_group_status_update(
     m_remote_group_peer.mirror_status_updater->set_mirror_group_status(
         m_global_group_id, remote_status, true);
   }
+  m_status_state = local_status.state;
+  m_state_desc = local_status.description;
 }
 
 } // namespace mirror
index 7c2d9e150895a86e58227358f888a995f134515d..a5341d21654e71d4f984626a15d3c9c36ccf81f6 100644 (file)
@@ -10,7 +10,7 @@
 #include "include/rados/librados.hpp"
 #include "tools/rbd_mirror/Types.h"
 #include "tools/rbd_mirror/group_replayer/Replayer.h"
-#include "tools/rbd_mirror/image_replayer/Types.h"
+#include "tools/rbd_mirror/group_replayer/Types.h"
 #include <boost/optional.hpp>
 #include <string>
 #include <list>
@@ -100,7 +100,7 @@ public:
 
   void sync_group_names();
 
-  image_replayer::HealthState get_health_state() const;
+  group_replayer::HealthState get_health_state() const;
 
   void add_peer(const Peer<ImageCtxT>& peer);
 
@@ -178,6 +178,9 @@ private:
     }
   };
 
+  typedef boost::optional<cls::rbd::MirrorGroupStatusState>
+      OptionalMirrorGroupStatusState;
+
   librados::IoCtx &m_local_io_ctx;
   std::string m_local_mirror_uuid;
   std::string m_global_group_id;
@@ -200,7 +203,8 @@ private:
   mutable ceph::mutex m_lock;
   State m_state = STATE_STOPPED;
   std::string m_state_desc;
-  cls::rbd::MirrorGroupStatusState m_status_state;
+  OptionalMirrorGroupStatusState m_status_state =
+    boost::make_optional(false, cls::rbd::MIRROR_GROUP_STATUS_STATE_UNKNOWN);
   int m_last_r = 0;
 
   Context *m_on_start_finish = nullptr;
index 9c573c6debae7d65da460f38f879d5030df1ba03..252fa801e47642b118672c5ff870957b1f2525ac 100644 (file)
@@ -709,9 +709,9 @@ void InstanceReplayer<I>::start_group_replayers(int r) {
 
     ++group_count;
     auto health_state = current_it->second->get_health_state();
-    if (health_state == image_replayer::HEALTH_STATE_WARNING) {
+    if (health_state == group_replayer::HEALTH_STATE_WARNING) {
       ++warning_count;
-    } else if (health_state == image_replayer::HEALTH_STATE_ERROR) {
+    } else if (health_state == group_replayer::HEALTH_STATE_ERROR) {
       ++error_count;
     }
 
index 7da1fd3b388c019833451333737fd679d083942e..1779fa47567a5169a2968e382bee677b1c72fcdf 100644 (file)
@@ -10,8 +10,7 @@
 #include "include/rados/librados.hpp"
 #include "librbd/mirror/snapshot/Types.h"
 #include "tools/rbd_mirror/Types.h"
-#include "tools/rbd_mirror/image_replayer/Replayer.h"
-#include "tools/rbd_mirror/image_replayer/Types.h"
+#include "tools/rbd_mirror/group_replayer/Types.h"
 #include <string>
 
 class Context;
diff --git a/src/tools/rbd_mirror/group_replayer/Types.h b/src/tools/rbd_mirror/group_replayer/Types.h
new file mode 100644 (file)
index 0000000..91f97d6
--- /dev/null
@@ -0,0 +1,21 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_RBD_MIRROR_GROUP_REPLAYER_TYPES_H
+#define CEPH_RBD_MIRROR_GROUP_REPLAYER_TYPES_H
+
+namespace rbd {
+namespace mirror {
+namespace group_replayer {
+
+enum HealthState {
+  HEALTH_STATE_OK,
+  HEALTH_STATE_WARNING,
+  HEALTH_STATE_ERROR
+};
+
+} // namespace group_replayer
+} // namespace mirror
+} // namespace rbd
+
+#endif // CEPH_RBD_MIRROR_GROUP_REPLAYER_TYPES_H