From d0c0beb8beb8a56fc61843b6dfa8b4b34c0a4ec1 Mon Sep 17 00:00:00 2001 From: Henrik Triem Date: Wed, 22 Jan 2020 16:57:31 +0100 Subject: [PATCH] Change behaviour of multiple dependencies (all failed = unreachable) --- lib/icinga/checkable-dependency.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/icinga/checkable-dependency.cpp b/lib/icinga/checkable-dependency.cpp index 10e39ab58..02ddfc12e 100644 --- a/lib/icinga/checkable-dependency.cpp +++ b/lib/icinga/checkable-dependency.cpp @@ -72,15 +72,25 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency } } - for (const Dependency::Ptr& dep : GetDependencies()) { + auto deps = GetDependencies(); + + int countFailed = 0; + + for (const Dependency::Ptr& dep : deps) { if (!dep->IsAvailable(dt)) { + countFailed++; + if (failedDependency) *failedDependency = dep; - - return false; } } + if (countFailed == deps.size()) { + Log(LogDebug, "Checkable") + << "All dependencies have failed for checkable '" << GetName() << "': Marking as unreachable."; + + return false; + } if (failedDependency) *failedDependency = nullptr;