]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/nvmeofgw*: fix HA usecase when gateway has no listeners: behaves like no-subsystems 60247/head
authorLeonid Chernin <leonidc@il.ibm.com>
Wed, 9 Oct 2024 06:59:09 +0000 (06:59 +0000)
committerLeonid Chernin <leonidc@il.ibm.com>
Thu, 10 Oct 2024 13:27:48 +0000 (13:27 +0000)
Signed-off-by: Leonid Chernin <leonidc@il.ibm.com>
src/mon/NVMeofGwMap.cc
src/mon/NVMeofGwMap.h
src/mon/NVMeofGwMon.cc

index 7b1bc9b8e56cf5c6c134479a784745485a43aa1a..c01ea9e71032163bcfb8b648e324352e0a825cbd 100755 (executable)
@@ -254,7 +254,7 @@ void NVMeofGwMap::track_deleting_gws(const NvmeGroupKey& group_key,
   }
 }
 
-int NVMeofGwMap::process_gw_map_gw_no_subsystems(
+int NVMeofGwMap::process_gw_map_gw_no_subsys_no_listeners(
   const NvmeGwId &gw_id, const NvmeGroupKey& group_key, bool &propose_pending)
 {
   int rc = 0;
@@ -424,7 +424,6 @@ void NVMeofGwMap::find_failback_gw(
   auto& gws_states = created_gws[group_key];
   auto& gw_state = created_gws[group_key][gw_id];
   bool do_failback = false;
-
   dout(10) << "Find failback GW for GW " << gw_id << dendl;
   for (auto& gw_state_it: gws_states) {
     auto& st = gw_state_it.second;
index 29710371742185d4b432f42c6f93ba73af41bbba..267d85b10f9184435b3d849a30db17af64ff3fe3 100755 (executable)
@@ -54,7 +54,7 @@ public:
   int process_gw_map_gw_down(
     const NvmeGwId &gw_id, const NvmeGroupKey& group_key,
     bool &propose_pending);
-  int process_gw_map_gw_no_subsystems(
+  int process_gw_map_gw_no_subsys_no_listeners(
     const NvmeGwId &gw_id, const NvmeGroupKey& group_key,
     bool &propose_pending);
   void update_active_timers(bool &propose_pending);
index 734e90defd946223008a241b071c1a157389ed6a..d9e936e27df34a8f292b7c711062b2fa1b19beb8 100644 (file)
@@ -367,6 +367,13 @@ bool NVMeofGwMon::preprocess_command(MonOpRequestRef op)
        std::stringstream  sstrm1;
        sstrm1 << state.availability;
        f->dump_string("Availability", sstrm1.str());
+       uint32_t num_listeners = 0;
+       if (state.availability == gw_availability_t::GW_AVAILABLE) {
+         for (auto &subs: state.subsystems) {
+           num_listeners += subs.listeners.size();
+         }
+         f->dump_unsigned("num-listeners", num_listeners);
+       }
        sstrm1.str("");
        for (auto &state_itr: map.created_gws[group_key][gw_id].sm_state) {
          sstrm1 << " " << state_itr.first + 1 << ": "
@@ -476,7 +483,7 @@ void NVMeofGwMon::process_gw_down(const NvmeGwId &gw_id,
     if (avail == gw_availability_t::GW_UNAVAILABLE) {
       pending_map.process_gw_map_gw_down(gw_id, group_key, propose_pending);
     } else {
-      pending_map.process_gw_map_gw_no_subsystems(gw_id, group_key, propose_pending);
+      pending_map.process_gw_map_gw_no_subsys_no_listeners(gw_id, group_key, propose_pending);
     }
 
   }
@@ -600,7 +607,18 @@ bool NVMeofGwMon::prepare_beacon(MonOpRequestRef op)
 
   if (sub.size() == 0) {
     avail = gw_availability_t::GW_CREATED;
-  }
+  } else {
+    bool listener_found = false;
+    for (auto &subs: sub) {
+      if (subs.listeners.size()) {
+        listener_found = true;
+        break;
+      }
+    }
+    if (!listener_found) {
+     avail = gw_availability_t::GW_CREATED;
+    }
+  }// for HA no-subsystems and no-listeners are same usecases
   if (pending_map.created_gws[group_key][gw_id].subsystems != sub) {
     dout(10) << "subsystems of GW changed, propose pending " << gw_id << dendl;
     pending_map.created_gws[group_key][gw_id].subsystems =  sub;