Skip to content

Commit 56cf512

Browse files
committed
mon/NVMeofGwMap: add delay to NVMEOF_GATEWAY_DELETING warning
Instead of immediately triggering, have this healthcheck trigger after some time has elasped. This delay can be configured by mon_nvmeofgw_delete_grace. Track the time when gateways go into DELETING state in a new member var (of NVMeofGwMon) 'gws_deleting_time'. Signed-off-by: Vallari Agrawal <[email protected]>
1 parent 7b33f77 commit 56cf512

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

src/mon/NVMeofGwMap.cc

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ int NVMeofGwMap::cfg_delete_gw(
171171
<< state.availability << " Resulting GW availability: "
172172
<< state.availability << dendl;
173173
state.subsystems.clear();//ignore subsystems of this GW
174+
utime_t now = ceph_clock_now();
175+
mon->nvmegwmon()->gws_deleting_time[group_key][gw_id] = now;
174176
return 0;
175177
}
176178
}
@@ -895,11 +897,12 @@ struct CMonRequestProposal : public Context {
895897
}
896898
};
897899

898-
void NVMeofGwMap::get_health_checks(health_check_map_t *checks) const
900+
void NVMeofGwMap::get_health_checks(health_check_map_t *checks)
899901
{
900902
list<string> singleGatewayDetail;
901903
list<string> gatewayDownDetail;
902904
list<string> gatewayInDeletingDetail;
905+
int deleting_gateways = 0;
903906
for (const auto& created_map_pair: created_gws) {
904907
const auto& group_key = created_map_pair.first;
905908
auto& group = group_key.second;
@@ -917,12 +920,36 @@ void NVMeofGwMap::get_health_checks(health_check_map_t *checks) const
917920
ss << "NVMeoF Gateway '" << gw_id << "' is unavailable." ;
918921
gatewayDownDetail.push_back(ss.str());
919922
} else if (gw_created.availability == gw_availability_t::GW_DELETING) {
920-
ostringstream ss;
921-
ss << "NVMeoF Gateway '" << gw_id << "' is in deleting state." ;
922-
gatewayInDeletingDetail.push_back(ss.str());
923+
deleting_gateways++;
924+
utime_t now = ceph_clock_now();
925+
bool found_deleting_time = false;
926+
auto gws_deleting_time = mon->nvmegwmon()->gws_deleting_time;
927+
auto group_it = gws_deleting_time.find(group_key);
928+
if (group_it != gws_deleting_time.end()) {
929+
auto& gw_map = group_it->second;
930+
auto gw_it = gw_map.find(gw_id);
931+
if (gw_it != gw_map.end()) {
932+
found_deleting_time = true;
933+
utime_t delete_time = gw_it->second;
934+
if ((now - delete_time) > g_conf().get_val<std::chrono::seconds>("mon_nvmeofgw_delete_grace").count()) {
935+
ostringstream ss;
936+
ss << "NVMeoF Gateway '" << gw_id << "' is in deleting state.";
937+
gatewayInDeletingDetail.push_back(ss.str());
938+
}
939+
}
940+
}
941+
if (!found_deleting_time) {
942+
// DELETING gateway not found in gws_deleting_time, set timeout now
943+
mon->nvmegwmon()->gws_deleting_time[group_key][gw_id] = now;
944+
}
923945
}
924946
}
925947
}
948+
if (deleting_gateways == 0) {
949+
// no gateway in GW_DELETING state currently, flush old gws_deleting_time
950+
mon->nvmegwmon()->gws_deleting_time.clear();
951+
}
952+
926953
if (!singleGatewayDetail.empty()) {
927954
ostringstream ss;
928955
ss << singleGatewayDetail.size() << " group(s) have only 1 nvmeof gateway"

src/mon/NVMeofGwMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class NVMeofGwMap
144144
DECODE_FINISH(bl);
145145
}
146146

147-
void get_health_checks(health_check_map_t *checks) const;
147+
void get_health_checks(health_check_map_t *checks);
148148
};
149149

150150
#include "NVMeofGwSerialize.h"

src/mon/NVMeofGwMon.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class NVMeofGwMon: public PaxosService,
8282
void check_subs(bool type);
8383
void check_sub(Subscription *sub);
8484

85+
std::map<NvmeGroupKey, std::map<NvmeGwId, utime_t>> gws_deleting_time;
86+
8587
private:
8688
void synchronize_last_beacon();
8789
void process_gw_down(const NvmeGwId &gw_id,

0 commit comments

Comments
 (0)