]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
location changes
authorLeonid Chernin <leonidc@il.ibm.com>
Mon, 24 Nov 2025 13:29:41 +0000 (15:29 +0200)
committerLeonid Chernin <leonidc@il.ibm.com>
Thu, 4 Dec 2025 14:47:37 +0000 (16:47 +0200)
 debug logs upon start-failback
 upgrade rule in set-location
Signed-off-by: Leonid Chernin <leonidc@il.ibm.com>
src/mon/MonCommands.h
src/mon/NVMeofGwMap.cc
src/mon/NVMeofGwMap.h
src/mon/NVMeofGwMon.cc

index 4f90abeaacc493f28bff5253bb757d961c8186ef..4a911937413e6b276e75d021fcf8c9cef68060bb 100644 (file)
@@ -1467,18 +1467,18 @@ COMMAND("nvme-gw disable"
    "administratively disables nvmeof gateway id for (pool, group)",
    "mgr", "rw")
 
-COMMAND("nvme-gw set-locale"
+COMMAND("nvme-gw set-location"
    " name=id,type=CephString"
    " name=pool,type=CephString"
    " name=group,type=CephString"
-   " name=locale,type=CephString",
+   " name=location,type=CephString",
    "set location for nvmeof gateway id for (pool, group)",
    "mgr", "rw")
 
 COMMAND("nvme-gw start-failback"
   " name=pool,type=CephString"
   " name=group,type=CephString"
-  " name=locale,type=CephString",
+  " name=location,type=CephString",
   "start failbacks for recovered location within (pool, group)",
   "mgr", "rw")
 
index d0062e8814faa7a97dbaa0d7c08081b8c866a655..94f56e85b1ef073457e53006dfe28b9554636c70 100755 (executable)
@@ -293,31 +293,63 @@ int NVMeofGwMap::cfg_admin_state_change(const NvmeGwId &gw_id,
   return 0;
 }
 
+bool NVMeofGwMap::validate_number_locations(int num_gws, int num_locations)
+{
+    int approved_locations;
+
+    if (num_gws <= 2) {
+      approved_locations = 1;
+    } else if (num_gws <= 6) {
+      approved_locations = 2;
+    } else {
+      approved_locations = 3;
+    }
+    return num_locations <= approved_locations;
+}
+
 int NVMeofGwMap::cfg_set_location(const NvmeGwId &gw_id,
     const NvmeGroupKey& group_key,
     std::string &location, bool &propose_pending, bool test) {
 // validate that location differs from gw location
     auto& gws_states = created_gws[group_key];
     auto  gw_state = gws_states.find(gw_id);
+    std::set<std::string>  locations;
+    if (!HAVE_FEATURE(mon->get_quorum_con_features(), NVMEOF_BEACON_DIFF)) {
+      dout(4) << "Command is not allowed - feature is not installed"
+              << group_key << " " << gw_id << dendl;
+      return -EINVAL;
+    }
+    int num_gws = gws_states.size();
     if (gw_state != gws_states.end()) {
       auto& st = gw_state->second;
       if (st.location == location) {
         dout(4) << "GW-id same location is set " << group_key
-        << " " << gw_id << " " << location << dendl;
+                << " " << gw_id << " " << location << dendl;
         return 0;
       }
       else {
-       //TODO check that old location still valid
-       // if location completely removed need to find namespaces
-       // belong to location - if found at least one - reject the command
        bool last_gw = true;
        for (auto& states: created_gws[group_key]) {
          auto &state = states.second;
+         // calculate number set locations
+         locations.insert(state.location);
          if (state.location == st.location && states.first != gw_id) {
            last_gw = false;
            break;
          }
        }
+       if (last_gw) { // this location would be removed so erase from set
+         locations.erase(st.location);
+       }
+       locations.insert(location);
+       dout(10) << "num GWs " << num_gws << " num set locations "
+                << locations.size() << dendl;
+       /*bool rc = validate_number_locations(num_gws, locations.size());
+       if (rc ==false) {
+         dout(4) << "Try to define invalid number of locations "
+                 << locations.size() << dendl;
+         return -EINVAL;
+       }*/
        if (last_gw) {
           //const BeaconSubsystems  subs;
           //int num = get_num_namespaces(gw_id, group_key, subs, st.location);
index 2ea20cd9cd3a2dd5fd0c5eac7e3067acfc6efb65..142d92a858f7b763ecae3211d9eee7ff0b524ad5 100755 (executable)
@@ -157,6 +157,7 @@ private:
   void increment_gw_epoch(const NvmeGroupKey& group_key);
   int find_failover_gw_logic(NvmeGwMonStates& gws_states,
     NvmeLocation& location, NvmeGwId& min_loaded_gw_id);
+  bool validate_number_locations(int num_gws, int num_locations);
 
 public:
   int blocklist_gw(
index e6a8f19b6a1c1ebaa56d629c19c86b2ad2997eea..361f4f4120eefc8005c49c51d4d13d9e3df5240a 100644 (file)
@@ -631,18 +631,18 @@ bool NVMeofGwMon::prepare_command(MonOpRequestRef op)
       if (rc == 0 && propose == true) {
         response = true;
       }
-  } else if (prefix == "nvme-gw set-locale") {
+  } else if (prefix == "nvme-gw set-location") {
 
-    std::string id, pool, group, locale;
+    std::string id, pool, group, location;
     cmd_getval(cmdmap, "id", id);
     cmd_getval(cmdmap, "pool", pool);
     cmd_getval(cmdmap, "group", group);
-    cmd_getval(cmdmap, "locale", locale);
+    cmd_getval(cmdmap, "location", location);
     auto group_key = std::make_pair(pool, group);
     dout(10) << " id "<< id <<" pool "<< pool << " group "<< group
-                   <<" locale "<< locale << dendl;
+             <<" location "<< location << dendl;
     bool propose = false;
-    rc = pending_map.cfg_set_location(id, group_key, locale, propose);
+    rc = pending_map.cfg_set_location(id, group_key, location, propose);
     if (rc == -EINVAL || rc == -EEXIST) {
       err = rc;
       dout (4) << "Error: GW cannot  set location " << id
@@ -657,16 +657,16 @@ bool NVMeofGwMon::prepare_command(MonOpRequestRef op)
       response = true;
     }
   } else if (prefix == "nvme-gw start-failback") {
-    std::string id, pool, group, locale;
+    std::string id, pool, group, location;
     bool propose = false;
     cmd_getval(cmdmap, "pool", pool);
     cmd_getval(cmdmap, "group", group);
-    cmd_getval(cmdmap, "locale", locale);
+    cmd_getval(cmdmap, "location", location);
     auto group_key = std::make_pair(pool, group);
     dout(10) << id <<" pool "<< pool << " group "<< group
-             <<" locale "<< locale << dendl;
+             <<" location "<< location << dendl;
     rc = pending_map.cfg_start_inter_location_failback(group_key,
-                     locale, propose);
+                     location, propose);
   }
   getline(sstrm, rs);
   if (response == false) {