From f63268b0dd0ce28e046afb1b72b084295babc408 Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Wed, 12 Jan 2022 15:33:15 +0100 Subject: [PATCH] Icinga DB: make downtime events update the state tables but not write state history StateChangeHandler() is the function used when the actual hard/soft state changes and thus also writes state history. This is not desired in this case, instead, a runtime update should be generated, therefore call UpdateState() instead. refs #9063 --- lib/icingadb/icingadb-objects.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index df8d3553a..b43e749dc 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -1800,6 +1800,9 @@ void IcingaDB::SendStartedDowntime(const Downtime::Ptr& downtime) Service::Ptr service; tie(host, service) = GetHostService(checkable); + /* Update checkable state as in_downtime may have changed. */ + UpdateState(checkable, StateUpdate::Full); + std::vector xAdd ({ "XADD", "icinga:history:stream:downtime", "*", "downtime_id", GetObjectIdentifier(downtime), @@ -1885,6 +1888,9 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime) if (downtime->GetTriggerTime() == 0) return; + /* Update checkable state as in_downtime may have changed. */ + UpdateState(checkable, StateUpdate::Full); + std::vector xAdd ({ "XADD", "icinga:history:stream:downtime", "*", "downtime_id", GetObjectIdentifier(downtime), @@ -2626,8 +2632,6 @@ void IcingaDB::VersionChangedHandler(const ConfigObject::Ptr& object) void IcingaDB::DowntimeStartedHandler(const Downtime::Ptr& downtime) { - StateChangeHandler(downtime->GetCheckable()); - for (auto& rw : ConfigType::GetObjectsByType()) { rw->SendStartedDowntime(downtime); } @@ -2635,8 +2639,6 @@ void IcingaDB::DowntimeStartedHandler(const Downtime::Ptr& downtime) void IcingaDB::DowntimeRemovedHandler(const Downtime::Ptr& downtime) { - StateChangeHandler(downtime->GetCheckable()); - for (auto& rw : ConfigType::GetObjectsByType()) { rw->SendRemovedDowntime(downtime); }