aboutsummaryrefslogtreecommitdiffstats
path: root/configd
diff options
context:
space:
mode:
authorArne Juul <arnej@verizonmedia.com>2021-06-10 11:02:06 +0000
committerArne Juul <arnej@verizonmedia.com>2021-06-10 11:02:06 +0000
commitdaee12941a469c993919b515a72439b631ee244e (patch)
tree932fcdf8068fe3614c69b39c653725c0f25f39aa /configd
parent5036748a5a18f1dee457a185ad42588f98010312 (diff)
split out some helper methods
Diffstat (limited to 'configd')
-rw-r--r--configd/src/apps/sentinel/connectivity.cpp61
-rw-r--r--configd/src/apps/sentinel/connectivity.h7
-rw-r--r--configd/src/apps/sentinel/outward-check.h2
3 files changed, 43 insertions, 27 deletions
diff --git a/configd/src/apps/sentinel/connectivity.cpp b/configd/src/apps/sentinel/connectivity.cpp
index 32d4d123a95..8d1aa0e9673 100644
--- a/configd/src/apps/sentinel/connectivity.cpp
+++ b/configd/src/apps/sentinel/connectivity.cpp
@@ -145,8 +145,7 @@ Connectivity::checkConnectivity(RpcServer &rpcServer) {
}
checkContext.latch.await();
classifyConnFails(connectivityMap, _checkSpecs, rpcServer);
- size_t numProblematic = 0;
- size_t numUpButBad = 0;
+ Accumulated accumulated;
for (const auto & [hostname, check] : connectivityMap) {
std::string detail = toString(check.result());
std::string prev = _detailsPerHost[hostname];
@@ -155,39 +154,47 @@ Connectivity::checkConnectivity(RpcServer &rpcServer) {
}
_detailsPerHost[hostname] = detail;
LOG_ASSERT(check.result() != CcResult::UNKNOWN);
- switch (check.result()) {
- case CcResult::UNREACHABLE_UP:
- case CcResult::INDIRECT_PING_FAIL:
- ++numUpButBad;
- ++numProblematic;
- break;
- case CcResult::CONN_FAIL:
- ++numProblematic;
- break;
- case CcResult::UNKNOWN:
- case CcResult::INDIRECT_PING_UNAVAIL:
- case CcResult::ALL_OK:
- break;
- }
+ accumulate(accumulated, check.result());
}
- bool allChecksOk = true;
- if (numUpButBad > size_t(_config.maxBadReverseCount)) {
+ return enoughOk(accumulated, clusterSize);
+}
+
+void Connectivity::accumulate(Accumulated &target, CcResult value) {
+ switch (value) {
+ case CcResult::UNKNOWN:
+ case CcResult::UNREACHABLE_UP:
+ case CcResult::INDIRECT_PING_FAIL:
+ ++target.numSeriousIssues;
+ ++target.numIssues;
+ break;
+ case CcResult::CONN_FAIL:
+ ++target.numIssues;
+ break;
+ case CcResult::INDIRECT_PING_UNAVAIL:
+ case CcResult::ALL_OK:
+ break;
+ }
+}
+
+bool Connectivity::enoughOk(const Accumulated &results, size_t clusterSize) {
+ bool enough = true;
+ if (results.numSeriousIssues > size_t(_config.maxBadReverseCount)) {
LOG(warning, "%zu of %zu nodes up but with network connectivity problems (max is %d)",
- numUpButBad, clusterSize, _config.maxBadReverseCount);
- allChecksOk = false;
+ results.numSeriousIssues, clusterSize, _config.maxBadReverseCount);
+ enough = false;
}
- if (numProblematic * 100.0 > _config.maxBadOutPercent * clusterSize) {
- double pct = numProblematic * 100.0 / clusterSize;
+ 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%%)",
- numProblematic, clusterSize, pct, _config.maxBadOutPercent);
- allChecksOk = false;
+ results.numIssues, clusterSize, pct, _config.maxBadOutPercent);
+ enough = false;
}
- if (numProblematic == 0) {
+ if (results.numIssues == 0) {
LOG(info, "All connectivity checks OK, proceeding with service startup");
- } else if (allChecksOk) {
+ } else if (enough) {
LOG(info, "Enough connectivity checks OK, proceeding with service startup");
}
- return allChecksOk;
+ return enough;
}
}
diff --git a/configd/src/apps/sentinel/connectivity.h b/configd/src/apps/sentinel/connectivity.h
index 03abd3dfc7a..47b773d3477 100644
--- a/configd/src/apps/sentinel/connectivity.h
+++ b/configd/src/apps/sentinel/connectivity.h
@@ -3,6 +3,7 @@
#pragma once
#include "rpcserver.h"
+#include "outward-check.h"
#include <vespa/config-sentinel.h>
#include <vespa/config-model.h>
#include <string>
@@ -26,6 +27,12 @@ public:
void configure(const SentinelConfig::Connectivity &config);
bool checkConnectivity(RpcServer &rpcServer);
private:
+ struct Accumulated {
+ size_t numIssues = 0;
+ size_t numSeriousIssues = 0;
+ };
+ 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;
diff --git a/configd/src/apps/sentinel/outward-check.h b/configd/src/apps/sentinel/outward-check.h
index 9aec52dc678..ab11eb74a71 100644
--- a/configd/src/apps/sentinel/outward-check.h
+++ b/configd/src/apps/sentinel/outward-check.h
@@ -1,5 +1,7 @@
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#pragma once
+
#include <string>
#include <vespa/vespalib/util/count_down_latch.h>
#include <vespa/fnet/frt/supervisor.h>