Skip to content

Commit

Permalink
fix: use event.series.count, default count to 1 for pod events
Browse files Browse the repository at this point in the history
Fix devfile#987

When checking workspace deployment pod events, first check event.series.count (as event.count is deprecated).
If event.series.count isin't set, fallback to event.count if it is set.
Otherwise, assume the event count is 1.

Signed-off-by: Andrew Obuchowicz <aobuchow@redhat.com>
  • Loading branch information
AObuchow committed Dec 1, 2022
1 parent f8a7592 commit 40ce94c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/library/status/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ func CheckPodEvents(pod *corev1.Pod, workspaceID string, ignoredEvents []string,
}

if maxCount, isUnrecoverableEvent := unrecoverablePodEventReasons[ev.Reason]; isUnrecoverableEvent {
if !checkIfUnrecoverableEventIgnored(ev.Reason, ignoredEvents) && ev.Count >= maxCount {
if !checkIfUnrecoverableEventIgnored(ev.Reason, ignoredEvents) && getEventCount(ev) >= maxCount {
var msg string
if ev.Count > 1 {
msg = fmt.Sprintf("Detected unrecoverable event %s %d times: %s.", ev.Reason, ev.Count, ev.Message)
if getEventCount(ev) > 1 {
msg = fmt.Sprintf("Detected unrecoverable event %s %d times: %s.", ev.Reason, getEventCount(ev), ev.Message)
} else {
msg = fmt.Sprintf("Detected unrecoverable event %s: %s.", ev.Reason, ev.Message)
}
Expand Down Expand Up @@ -181,3 +181,12 @@ func checkPodConditions(pod *corev1.Pod) (msg string) {
}
return ""
}

func getEventCount(event corev1.Event) int32 {
if event.Series != nil {
return event.Series.Count
} else if event.Count > 0 {
return event.Count
}
return 1
}

0 comments on commit 40ce94c

Please sign in to comment.