From: Michael Friedrich Date: Sun, 12 Apr 2015 12:38:35 +0000 (+0200) Subject: Trigger downtimes for NOT-OK states after OnDowntimeAdded() X-Git-Tag: v2.3.4~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e659784a66d9651622487f0a0bb50a509acc134b;p=icinga2 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 --- 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; }