summaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-06-11 14:48:47 +0000
committerArne Juul <arnej@verizonmedia.com>2021-06-11 14:48:47 +0000
commit339b58f9437e0c60cc8107aa0252a783d2790e27 (patch)
tree21c440ad72ab1be1487c19e14ed20be554532a84 /configd
parentdb8530327e2b5348239925013366665c012381d9 (diff)
parentf163dd2b355819e490fd8f2e0327a3a6950bb94a (diff)
Merge branch 'master' into arnej/add-report-connectivity-rpc
Conflicts: configd/src/apps/sentinel/connectivity.cpp
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/sentinel/connectivity.cpp35
-rw-r--r--configd/src/apps/sentinel/connectivity.h13
2 files changed, 26 insertions, 22 deletions
diff --git a/configd/src/apps/sentinel/connectivity.cpp b/configd/src/apps/sentinel/connectivity.cpp
index 8314a090616..c1c49e3068a 100644
--- a/configd/src/apps/sentinel/connectivity.cpp
+++ b/configd/src/apps/sentinel/connectivity.cpp
@@ -120,8 +120,8 @@ void Connectivity::configure(const SentinelConfig::Connectivity &config,
const ModelConfig &model)
{
_config = config;
- LOG(config, "connectivity.maxBadReverseCount = %d", _config.maxBadReverseCount);
- LOG(config, "connectivity.maxBadOutPercent = %d", _config.maxBadOutPercent);
+ LOG(config, "connectivity.maxBadCount = %d", _config.maxBadCount);
+ LOG(config, "connectivity.minOkPercent = %d", _config.minOkPercent);
_checkSpecs = specsFrom(model);
}
@@ -143,7 +143,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];
@@ -152,42 +152,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;
- ++target.numIssues;
+ ++_numBad;
break;
case CcResult::CONN_FAIL:
- ++target.numIssues;
+ // not OK, but not a serious issue either
break;
case CcResult::INDIRECT_PING_UNAVAIL:
case CcResult::ALL_OK:
+ ++_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.maxBadReverseCount)) {
+ 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.maxBadReverseCount);
+ _numBad, _numHandled, config.maxBadCount);
enough = false;
}
- if (results.numIssues * 100.0 > _config.maxBadOutPercent * clusterSize) {
- double pct = results.numIssues * 100.0 / clusterSize;
- LOG(warning, "Problems with connection to %zu of %zu nodes, %.1f%% (max is %d%%)",
- results.numIssues, clusterSize, pct, _config.maxBadOutPercent);
+ 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%%)",
+ _numOk, _numHandled, pct, config.minOkPercent);
enough = false;
}
- if (results.numIssues == 0) {
+ 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");
diff --git a/configd/src/apps/sentinel/connectivity.h b/configd/src/apps/sentinel/connectivity.h
index 2ba17f5c07c..8d923387ffa 100644
--- a/configd/src/apps/sentinel/connectivity.h
+++ b/configd/src/apps/sentinel/connectivity.h
@@ -29,12 +29,15 @@ public:
bool checkConnectivity(RpcServer &rpcServer);
static SpecMap specsFrom(const ModelConfig &model);
private:
- struct Accumulated {
- size_t numIssues = 0;
- size_t numSeriousIssues = 0;
+ class Accumulator {
+ private:
+ size_t _numOk = 0;
+ size_t _numBad = 0;
+ size_t _numHandled = 0;
+ public:
+ void handleResult(CcResult value);
+ bool enoughOk(const SentinelConfig::Connectivity &config) const;
};
- void accumulate(Accumulated &target, CcResult value);
- bool enoughOk(const Accumulated &results, size_t clusterSize);
SentinelConfig::Connectivity _config;
SpecMap _checkSpecs;
std::map<std::string, std::string> _detailsPerHost;