Skip to content

Commit 8c380a1

Browse files
committed
client_api: Fix logging & add some comments
1 parent 0ff79aa commit 8c380a1

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

internal/icinga2/client_api.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,7 @@ func (client *Client) listenEventStream() error {
440440
case *StateChange:
441441
// Ignore any state changes while in downtime
442442
if respT.DowntimeDepth > 0 {
443-
stateType := "HARD"
444-
if respT.StateType == StateTypeSoft {
445-
stateType = "SOFT"
446-
}
447-
448-
client.Logger.Debugf("Skipping %q state change while in downtime, %#v", stateType, respT)
443+
client.Logger.Debugf("Skipping state change, checkable is in downtime, %#v", respT)
449444
continue
450445
}
451446

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

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

0 commit comments

Comments
 (0)