Merge pull request #9171 from Icinga/bugfix/icinga-db-notification-history-might-use-incorrect-previous_hard_state-9132

IcingaDB#SendSentNotification(): make stream deterministic via CheckResult#previous_hard_state
This commit is contained in:
Julian Brost 2022-01-18 16:54:16 +01:00 committed by GitHub
commit 463b159414
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View File

@ -326,6 +326,8 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
SetLastSoftStatesRaw(GetLastSoftStatesRaw() / 100u + new_state * 100u);
}
cr->SetPreviousHardState(ServiceState(GetLastHardStatesRaw() % 100u));
if (!IsStateOK(new_state))
TriggerDowntimes(cr->GetExecutionEnd());

View File

@ -53,6 +53,7 @@ class CheckResult
[state] int exit_status;
[state, enum] ServiceState "state";
[state, enum] ServiceState previous_hard_state;
[state] String output;
[state] Array::Ptr performance_data;

View File

@ -1741,7 +1741,7 @@ void IcingaDB::SendSentNotification(
"host_id", GetObjectIdentifier(host),
"type", Convert::ToString(type),
"state", Convert::ToString(cr ? service ? Convert::ToLong(cr->GetState()) : Convert::ToLong(Host::CalculateState(cr->GetState())) : 99),
"previous_hard_state", Convert::ToString(GetPreviousState(checkable, service, StateTypeHard)),
"previous_hard_state", Convert::ToString(cr ? Convert::ToLong(service ? cr->GetPreviousHardState() : Host::CalculateState(cr->GetPreviousHardState())) : 99),
"author", Utility::ValidateUTF8(author),
"text", Utility::ValidateUTF8(finalText),
"users_notified", Convert::ToString(usersAmount),