aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/connectivity.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'configd/src/apps/sentinel/connectivity.cpp')
-rw-r--r--configd/src/apps/sentinel/connectivity.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/configd/src/apps/sentinel/connectivity.cpp b/configd/src/apps/sentinel/connectivity.cpp
index 2cdd6f8a914..0e91b583868 100644
--- a/configd/src/apps/sentinel/connectivity.cpp
+++ b/configd/src/apps/sentinel/connectivity.cpp
@@ -145,7 +145,7 @@ Connectivity::checkConnectivity(RpcServer &rpcServer) {
}
checkContext.latch.await();
classifyConnFails(connectivityMap, _checkSpecs, rpcServer);
- Accumulated accumulated;
+ Accumulator accumulated;
for (const auto & [hostname, check] : connectivityMap) {
std::string detail = toString(check.result());
std::string prev = _detailsPerHost[hostname];
@@ -154,42 +154,43 @@ Connectivity::checkConnectivity(RpcServer &rpcServer) {
}
_detailsPerHost[hostname] = detail;
LOG_ASSERT(check.result() != CcResult::UNKNOWN);
- accumulate(accumulated, check.result());
+ accumulated.handleResult(check.result());
}
- return enoughOk(accumulated, clusterSize);
+ return accumulated.enoughOk(_config);
}
-void Connectivity::accumulate(Accumulated &target, CcResult value) {
+void Connectivity::Accumulator::handleResult(CcResult value) {
+ ++_numHandled;
switch (value) {
case CcResult::UNKNOWN:
case CcResult::UNREACHABLE_UP:
case CcResult::INDIRECT_PING_FAIL:
- ++target.numSeriousIssues;
+ ++_numBad;
break;
case CcResult::CONN_FAIL:
// not OK, but not a serious issue either
break;
case CcResult::INDIRECT_PING_UNAVAIL:
case CcResult::ALL_OK:
- ++target.numUpAndOk;
+ ++_numOk;
break;
}
}
-bool Connectivity::enoughOk(const Accumulated &results, size_t clusterSize) {
+bool Connectivity::Accumulator::enoughOk(const SentinelConfig::Connectivity &config) const {
bool enough = true;
- if (results.numSeriousIssues > size_t(_config.maxBadCount)) {
+ if (_numBad > size_t(config.maxBadCount)) {
LOG(warning, "%zu of %zu nodes up but with network connectivity problems (max is %d)",
- results.numSeriousIssues, clusterSize, _config.maxBadCount);
+ _numBad, _numHandled, config.maxBadCount);
enough = false;
}
- if (results.numUpAndOk * 100.0 < _config.minOkPercent * clusterSize) {
- double pct = results.numUpAndOk * 100.0 / clusterSize;
+ if (_numOk * 100.0 < config.minOkPercent * _numHandled) {
+ double pct = _numOk * 100.0 / _numHandled;
LOG(warning, "Only %zu of %zu nodes are up and OK, %.1f%% (min is %d%%)",
- results.numUpAndOk, clusterSize, pct, _config.minOkPercent);
+ _numOk, _numHandled, pct, config.minOkPercent);
enough = false;
}
- if (results.numUpAndOk == clusterSize) {
+ if (_numOk == _numHandled) {
LOG(info, "All connectivity checks OK, proceeding with service startup");
} else if (enough) {
LOG(info, "Enough connectivity checks OK, proceeding with service startup");