From: Leonid Chernin Date: Mon, 24 Nov 2025 13:29:41 +0000 (+0200) Subject: location changes X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0781eeb90cc28dd07f2394b38fefd9c2cd95a19a;p=ceph-ci.git location changes debug logs upon start-failback upgrade rule in set-location Signed-off-by: Leonid Chernin --- diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 4f90abeaacc..4a911937413 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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") diff --git a/src/mon/NVMeofGwMap.cc b/src/mon/NVMeofGwMap.cc index d0062e8814f..94f56e85b1e 100755 --- a/src/mon/NVMeofGwMap.cc +++ b/src/mon/NVMeofGwMap.cc @@ -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 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); diff --git a/src/mon/NVMeofGwMap.h b/src/mon/NVMeofGwMap.h index 2ea20cd9cd3..142d92a858f 100755 --- a/src/mon/NVMeofGwMap.h +++ b/src/mon/NVMeofGwMap.h @@ -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( diff --git a/src/mon/NVMeofGwMon.cc b/src/mon/NVMeofGwMon.cc index e6a8f19b6a1..361f4f4120e 100644 --- a/src/mon/NVMeofGwMon.cc +++ b/src/mon/NVMeofGwMon.cc @@ -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) {