aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/connectivity.cpp
diff options
context:
space:
mode:
authorArne H Juul <arnej27959@users.noreply.github.com>2021-06-13 12:10:40 +0200
committerGitHub <noreply@github.com>2021-06-13 12:10:40 +0200
commit39ed7a2516c2512fbf3df805196cbb5d5f3a9519 (patch)
tree7a97a21be6b49d89292bde82eb9ef1397bb7f10e /configd/src/apps/sentinel/connectivity.cpp
parentc714172b49feaa6d0dcce819935e7bd7d26aa5a2 (diff)
parente3a93a6bfd8b90ced59f458675685ca7a45c9ded (diff)
Merge pull request #18197 from vespa-engine/arnej/add-report-connectivity-rpc
add rpc method for connectivity report
Diffstat (limited to 'configd/src/apps/sentinel/connectivity.cpp')
-rw-r--r--configd/src/apps/sentinel/connectivity.cpp54
1 files changed, 26 insertions, 28 deletions
diff --git a/configd/src/apps/sentinel/connectivity.cpp b/configd/src/apps/sentinel/connectivity.cpp
index 0e91b583868..c1c49e3068a 100644
--- a/configd/src/apps/sentinel/connectivity.cpp
+++ b/configd/src/apps/sentinel/connectivity.cpp
@@ -17,8 +17,6 @@ using namespace std::chrono_literals;
namespace config::sentinel {
-constexpr std::chrono::milliseconds MODEL_TIMEOUT_MS = 60s;
-
Connectivity::Connectivity() = default;
Connectivity::~Connectivity() = default;
@@ -45,28 +43,6 @@ std::string spec(const SpecMap::value_type &host_and_port) {
return fmt("tcp/%s:%d", host_and_port.first.c_str(), host_and_port.second);
}
-SpecMap specsFrom(const ModelConfig &model) {
- SpecMap checkSpecs;
- for (const auto & h : model.hosts) {
- bool foundSentinelPort = false;
- for (const auto & s : h.services) {
- if (s.name == "config-sentinel") {
- for (const auto & p : s.ports) {
- if (p.tags.find("rpc") != p.tags.npos) {
- checkSpecs[h.name] = p.number;
- foundSentinelPort = true;
- }
- }
- }
- }
- if (! foundSentinelPort) {
- LOG(warning, "Did not find 'config-sentinel' RPC port in model for host %s [%zd services]",
- h.name.c_str(), h.services.size());
- }
- }
- return checkSpecs;
-}
-
void classifyConnFails(ConnectivityMap &connectivityMap,
const SpecMap &specMap,
RpcServer &rpcServer)
@@ -118,13 +94,35 @@ void classifyConnFails(ConnectivityMap &connectivityMap,
} // namespace <unnamed>
-void Connectivity::configure(const SentinelConfig::Connectivity &config) {
+SpecMap Connectivity::specsFrom(const ModelConfig &model) {
+ SpecMap checkSpecs;
+ for (const auto & h : model.hosts) {
+ bool foundSentinelPort = false;
+ for (const auto & s : h.services) {
+ if (s.name == "config-sentinel") {
+ for (const auto & p : s.ports) {
+ if (p.tags.find("rpc") != p.tags.npos) {
+ checkSpecs[h.name] = p.number;
+ foundSentinelPort = true;
+ }
+ }
+ }
+ }
+ if (! foundSentinelPort) {
+ LOG(warning, "Did not find 'config-sentinel' RPC port in model for host %s [%zd services]",
+ h.name.c_str(), h.services.size());
+ }
+ }
+ return checkSpecs;
+}
+
+void Connectivity::configure(const SentinelConfig::Connectivity &config,
+ const ModelConfig &model)
+{
_config = config;
LOG(config, "connectivity.maxBadCount = %d", _config.maxBadCount);
LOG(config, "connectivity.minOkPercent = %d", _config.minOkPercent);
- if (auto up = ConfigOwner::fetchModelConfig(MODEL_TIMEOUT_MS)) {
- _checkSpecs = specsFrom(*up);
- }
+ _checkSpecs = specsFrom(model);
}
bool