Icinga / icinga-notifications

Icinga Notifications: new and improved notifications and incident management for Icinga (work in progress, not ready for production yet)
GNU General Public License v2.0
10 stars 0 forks source link

icinga2: Reset `Event#ID` before resending ack set event #243

Closed yhabteab closed 4 months ago

yhabteab commented 4 months ago

Event#Sync() synchronises an event row with the database only if its ID is set to no other value than 0. Therefore, we must reset the event ID for the acknowledgement set event generated in the catch-up phase before resending it.

yhabteab commented 4 months ago

If it is synced here, there should be no problems. The real problem, however, is that if there is an existing incident, that fake event will make its way to the fellowing scopes multiple times. https://github.com/Icinga/icinga-notifications/blob/59861289ce06d4b264f1b42e941d3b520cba332a/internal/incident/incident.go#L147 https://github.com/Icinga/icinga-notifications/blob/59861289ce06d4b264f1b42e941d3b520cba332a/internal/incident/incident.go#L163-L164

When the incident finally notices that this ack set event is superfluous here ... https://github.com/Icinga/icinga-notifications/blob/59861289ce06d4b264f1b42e941d3b520cba332a/internal/incident/incident.go#L199-L200 It will simply return without committing the transaction, leaving the now dangling ev.ID set above.