Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide cancel_time in Icinga DB downtime history where has_been_cancelled may be 1 #9896

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/icingadb/icingadb-objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,7 @@ void IcingaDB::SendStartedDowntime(const Downtime::Ptr& downtime)
"scheduled_end_time", Convert::ToString(TimestampToMilliseconds(downtime->GetEndTime())),
"has_been_cancelled", Convert::ToString((unsigned short)downtime->GetWasCancelled()),
"trigger_time", Convert::ToString(TimestampToMilliseconds(downtime->GetTriggerTime())),
"cancel_time", Convert::ToString(TimestampToMilliseconds(downtime->GetRemoveTime())),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't harm to include it, but it's rather strange to send cancel_time for a downtime_start event that would contain 0 anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"would" is the most important word here. If for some reason this goes wrong, I want

  • to know it via history
  • no Icinga DB crash

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no Icinga DB crash

That's the primary objective of this PR.

  • to know it via history

Know what? I mean a possible alternative could be to just remove has_been_cancelled from the start event altogether as that doesn't really make sense here (note: I didn't check/test how Icinga DB will behave in that case) and should be set in the end event. The downtime start and end events affect the same row in downtime_history anyways, so you can't tell which of both even set cancel_time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. 2023-12-19 15:09:14 2023-12-19T14:09:14.260Z FATAL icingadb Error 1048 (23000): Column 'has_been_cancelled' cannot be null

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because the DB column is not nullable. How about just sending a hardcoded 0 for has_been_cancelled then? I mean, this is a downtime start event, we don't need to set this to a meaningful value as it is guaranteed to be synchronised with the downtime end event.

"has_been_cancelled", Convert::ToString((unsigned short)downtime->GetWasCancelled()),
"trigger_time", Convert::ToString(TimestampToMilliseconds(downtime->GetTriggerTime())),
"cancel_time", Convert::ToString(TimestampToMilliseconds(downtime->GetRemoveTime())),

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds so cheaty, that's literally fake info.

"event_id", CalcEventID("downtime_start", downtime),
"event_type", "downtime_start"
});
Expand Down
Loading