mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Merge pull request #8560 from Icinga/bugfix/children-recover-too-late
On recovery: re-check children
This commit is contained in:
commit
d17b4ecc4b
@ -242,6 +242,20 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
||||
OnReachabilityChanged(this, cr, children, origin);
|
||||
}
|
||||
|
||||
if (recovery) {
|
||||
for (auto& child : children) {
|
||||
if (child->GetProblem() && child->GetEnableActiveChecks()) {
|
||||
auto nextCheck (now + Utility::Random() % 60);
|
||||
|
||||
ObjectLock oLock (child);
|
||||
|
||||
if (nextCheck < child->GetNextCheck()) {
|
||||
child->SetNextCheck(nextCheck);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!reachable)
|
||||
SetLastStateUnreachable(Utility::GetTime());
|
||||
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/exception.hpp"
|
||||
#include "base/context.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/lazy-init.hpp"
|
||||
#include "remote/apilistener.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
@ -145,6 +146,28 @@ static void FireSuppressedNotifications(Checkable* checkable)
|
||||
|
||||
int subtract = 0;
|
||||
|
||||
{
|
||||
LazyInit<bool> wasLastParentRecoveryRecent ([&checkable]() {
|
||||
auto cr (checkable->GetLastCheckResult());
|
||||
|
||||
if (!cr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
auto threshold (cr->GetExecutionStart());
|
||||
|
||||
for (auto& dep : checkable->GetDependencies()) {
|
||||
auto parent (dep->GetParent());
|
||||
ObjectLock oLock (parent);
|
||||
|
||||
if (!parent->GetProblem() && parent->GetLastStateChange() >= threshold) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
for (auto type : {NotificationProblem, NotificationRecovery, NotificationFlappingStart, NotificationFlappingEnd}) {
|
||||
if (suppressed_types & type) {
|
||||
bool still_applies;
|
||||
@ -205,7 +228,7 @@ static void FireSuppressedNotifications(Checkable* checkable)
|
||||
still_suppressed = checkable->GetNextCheck() <= Utility::GetTime() + threshold;
|
||||
}
|
||||
|
||||
if (!still_suppressed) {
|
||||
if (!still_suppressed && !wasLastParentRecoveryRecent.Get()) {
|
||||
Checkable::OnNotificationsRequested(checkable, type, cr, "", "", nullptr);
|
||||
|
||||
subtract |= type;
|
||||
@ -215,6 +238,7 @@ static void FireSuppressedNotifications(Checkable* checkable)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (subtract) {
|
||||
ObjectLock olock (checkable);
|
||||
|
Loading…
x
Reference in New Issue
Block a user