From e659784a66d9651622487f0a0bb50a509acc134b Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 12 Apr 2015 14:38:35 +0200 Subject: [PATCH] Trigger downtimes for NOT-OK states after OnDowntimeAdded() The fix in #8389 must happen *after* adding the downtime which signals an insert into the IDO DB. Once the downtimes have been added to the database, the additional trigger_time and is_in_effect can be updated accordingly, *if* the current object is already in a NOT-OK state. fixes #9016 --- lib/icinga/checkable-downtime.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/icinga/checkable-downtime.cpp b/lib/icinga/checkable-downtime.cpp index e32b5356a..bfeda84b2 100644 --- a/lib/icinga/checkable-downtime.cpp +++ b/lib/icinga/checkable-downtime.cpp @@ -104,14 +104,6 @@ String Checkable::AddDowntime(const String& author, const String& comment, l_DowntimesCache[uid] = this; } - /* if this object is already in a NOT-OK state trigger this downtime now */ - if (GetStateRaw() != ServiceOK) { - Log(LogNotice, "Checkable") - << "Checkable '" << GetName() << "' already in a NOT-OK state." - << " Triggering downtime now."; - TriggerDowntime(uid); - } - Log(LogNotice, "Checkable") << "Added downtime with ID '" << downtime->GetLegacyId() << "' between '" << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", startTime) @@ -119,6 +111,17 @@ String Checkable::AddDowntime(const String& author, const String& comment, OnDowntimeAdded(this, downtime, origin); + /* if this object is already in a NOT-OK state trigger + * this downtime now *after* it has been added (important + * for DB IDO, etc.) + */ + if (GetStateRaw() != ServiceOK) { + Log(LogNotice, "Checkable") + << "Checkable '" << GetName() << "' already in a NOT-OK state." + << " Triggering downtime now."; + TriggerDowntime(uid); + } + return uid; } -- 2.40.0