icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Icinga DB: inconsistent `state_type` value for volatile checks

Open yhabteab opened this issue 5 months ago • 1 comments

Describe the bug

Icinga 2 allows to treat every state change as a hard state change with the additional volatile checkable option, howver, the state_type of the respective checkable doesn't reflect that. As it can be seen below, the StateChange event is always triggered for volatile checks even hardChange is still false: https://github.com/Icinga/icinga2/blob/91eeb41ff1d65d3ac068eedf68a3cd7b5e4468ef/lib/icinga/checkable-check.cpp#L412-L413

Since that event includes the type of the state change as an extra argument, the Icinga DB histories are generated correctly based ont that. https://github.com/Icinga/icinga2/blob/91eeb41ff1d65d3ac068eedf68a3cd7b5e4468ef/lib/icingadb/icingadb-objects.cpp#L1912-L1916

However, that very same handler also implicitly triggers a runtime state update for that very same state change here: https://github.com/Icinga/icinga2/blob/91eeb41ff1d65d3ac068eedf68a3cd7b5e4468ef/lib/icingadb/icingadb-objects.cpp#L1885

Which looses the extra StateType argument, and thus it will just serialize the host state, and since the checkable's state_type was never updated to hard, the resulting JSON will contain state_type soft because it actually is a soft state change but due to the volatile flag, it was treated as a hard state change. This either needs to be fixed in ProcessCheckResult or Icinga DB should take the Volatile flag into account when serializing the state.

Your Environment

N/A

Additional context

Add any other context about the problem here.

yhabteab avatar Jun 15 '26 11:06 yhabteab

I have submitted a pr related to this issue, kindly assign me this issue

Akulbanxal avatar Aug 03 '26 15:08 Akulbanxal