Skip to content

Commit

Permalink
client_api: Fix logging & add some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yhabteab committed Apr 26, 2024
1 parent 0ff79aa commit 8c380a1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions internal/icinga2/client_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,7 @@ func (client *Client) listenEventStream() error {
case *StateChange:
// Ignore any state changes while in downtime
if respT.DowntimeDepth > 0 {
stateType := "HARD"
if respT.StateType == StateTypeSoft {
stateType = "SOFT"
}

client.Logger.Debugf("Skipping %q state change while in downtime, %#v", stateType, respT)
client.Logger.Debugf("Skipping state change, checkable is in downtime, %#v", respT)
continue
}

Expand Down Expand Up @@ -473,13 +468,17 @@ func (client *Client) listenEventStream() error {
evTime = respT.Timestamp.Time()
case *DowntimeStarted:
if !respT.Downtime.IsFixed {
// This may never happen, but Icinga 2 does the same thing, and we need to ignore the start
// event for flexible downtime, as there will definitely be a triggered event for it.
continue
}

ev, err = client.buildDowntimeEvent(client.Ctx, respT.Downtime, true)
evTime = respT.Timestamp.Time()
case *DowntimeTriggered:
if respT.Downtime.IsFixed {
// Fixed downtimes generate two events (start, triggered), the latter applies here and must
// be ignored, since we're going to process its start event to avoid duplicated notifications.
continue
}

Expand Down

0 comments on commit 8c380a1

Please sign in to comment.