diff options
author | Arne Juul <arnej@verizonmedia.com> | 2021-06-04 13:53:16 +0000 |
---|---|---|
committer | Arne Juul <arnej@verizonmedia.com> | 2021-06-04 14:29:00 +0000 |
commit | fb725932a4a9e0b206d79282606e046761caea70 (patch) | |
tree | dd10a5f61af69d164edaacc85ae3efb77a594934 /configd/src | |
parent | 684ae2d6e3370da6d9ed1c56e29d00590c0b45de (diff) |
minor fixes for detail logging
Diffstat (limited to 'configd/src')
-rw-r--r-- | configd/src/apps/sentinel/connectivity.cpp | 6 | ||||
-rw-r--r-- | configd/src/apps/sentinel/connectivity.h | 1 | ||||
-rw-r--r-- | configd/src/apps/sentinel/env.cpp | 12 |
3 files changed, 11 insertions, 8 deletions
diff --git a/configd/src/apps/sentinel/connectivity.cpp b/configd/src/apps/sentinel/connectivity.cpp index 9cced1d3475..7d9134ca51f 100644 --- a/configd/src/apps/sentinel/connectivity.cpp +++ b/configd/src/apps/sentinel/connectivity.cpp @@ -16,6 +16,12 @@ using namespace std::chrono_literals; namespace config::sentinel { +void Connectivity::CheckResult::logDetails() const { + for (const std::string &detail : details) { + LOG(info, "Connectivity check details: %s", detail.c_str()); + } +} + Connectivity::Connectivity(const SentinelConfig::Connectivity & config, RpcServer &rpcServer) : _config(config), _rpcServer(rpcServer) diff --git a/configd/src/apps/sentinel/connectivity.h b/configd/src/apps/sentinel/connectivity.h index 0e32b5243e0..69cea835da6 100644 --- a/configd/src/apps/sentinel/connectivity.h +++ b/configd/src/apps/sentinel/connectivity.h @@ -25,6 +25,7 @@ public: bool enoughOk; bool allOk; std::vector<std::string> details; + void logDetails() const; }; CheckResult checkConnectivity(const ModelConfig &model); diff --git a/configd/src/apps/sentinel/env.cpp b/configd/src/apps/sentinel/env.cpp index 189be7a53b7..ded615a3c4a 100644 --- a/configd/src/apps/sentinel/env.cpp +++ b/configd/src/apps/sentinel/env.cpp @@ -114,30 +114,26 @@ void Env::respondAsEmpty() { } bool Env::waitForConnectivity(int outerRetry) { - Connectivity::CheckResult lastCheckResult; auto up = ConfigOwner::fetchModelConfig(MODEL_TIMEOUT_MS); if (! up) { LOG(warning, "could not get model config, skipping connectivity checks"); return true; } + Connectivity::CheckResult lastCheckResult; Connectivity checker(_cfgOwner.getConfig().connectivity, *_rpcServer); for (int retry = 0; retry < maxRetriesInsideLoop; ++retry) { auto res = checker.checkConnectivity(*up); if (res.enoughOk) { LOG(info, "Connectivity check OK, proceeding with service startup"); - if (! res.allOk) { - for (const std::string &detail : res.details) { - LOG(info, "Connectivity check details: %s", detail.c_str()); - } + if (retry > 0 || ! res.allOk) { + res.logDetails(); } return true; } LOG(warning, "Connectivity check FAILED (try %d)", 1 + retry + maxRetriesInsideLoop*outerRetry); _stateApi.myHealth.setFailed("FAILED connectivity check"); if (lastCheckResult.details != res.details) { - for (const std::string &detail : res.details) { - LOG(info, "Connectivity check details: %s", detail.c_str()); - } + res.logDetails(); lastCheckResult = std::move(res); } for (int i = 0; i <= outerRetry; ++i) { |