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
This commit is contained in:
Julian Brost 2022-01-12 15:33:15 +01:00
parent 447884be72
commit f63268b0dd
1 changed files with 6 additions and 4 deletions

View File

@ -1800,6 +1800,9 @@ void IcingaDB::SendStartedDowntime(const Downtime::Ptr& downtime)
Service::Ptr service; Service::Ptr service;
tie(host, service) = GetHostService(checkable); tie(host, service) = GetHostService(checkable);
/* Update checkable state as in_downtime may have changed. */
UpdateState(checkable, StateUpdate::Full);
std::vector<String> xAdd ({ std::vector<String> xAdd ({
"XADD", "icinga:history:stream:downtime", "*", "XADD", "icinga:history:stream:downtime", "*",
"downtime_id", GetObjectIdentifier(downtime), "downtime_id", GetObjectIdentifier(downtime),
@ -1885,6 +1888,9 @@ void IcingaDB::SendRemovedDowntime(const Downtime::Ptr& downtime)
if (downtime->GetTriggerTime() == 0) if (downtime->GetTriggerTime() == 0)
return; return;
/* Update checkable state as in_downtime may have changed. */
UpdateState(checkable, StateUpdate::Full);
std::vector<String> xAdd ({ std::vector<String> xAdd ({
"XADD", "icinga:history:stream:downtime", "*", "XADD", "icinga:history:stream:downtime", "*",
"downtime_id", GetObjectIdentifier(downtime), "downtime_id", GetObjectIdentifier(downtime),
@ -2626,8 +2632,6 @@ void IcingaDB::VersionChangedHandler(const ConfigObject::Ptr& object)
void IcingaDB::DowntimeStartedHandler(const Downtime::Ptr& downtime) void IcingaDB::DowntimeStartedHandler(const Downtime::Ptr& downtime)
{ {
StateChangeHandler(downtime->GetCheckable());
for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->SendStartedDowntime(downtime); rw->SendStartedDowntime(downtime);
} }
@ -2635,8 +2639,6 @@ void IcingaDB::DowntimeStartedHandler(const Downtime::Ptr& downtime)
void IcingaDB::DowntimeRemovedHandler(const Downtime::Ptr& downtime) void IcingaDB::DowntimeRemovedHandler(const Downtime::Ptr& downtime)
{ {
StateChangeHandler(downtime->GetCheckable());
for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) { for (auto& rw : ConfigType::GetObjectsByType<IcingaDB>()) {
rw->SendRemovedDowntime(downtime); rw->SendRemovedDowntime(downtime);
} }