Skip to content

Skip empty messages when aggregating pending-pod event-check results#4896

Open
dejanzele wants to merge 1 commit intoarmadaproject:masterfrom
dejanzele:fix-podchecks-skip-empty-event-messages
Open

Skip empty messages when aggregating pending-pod event-check results#4896
dejanzele wants to merge 1 commit intoarmadaproject:masterfrom
dejanzele:fix-podchecks-skip-empty-event-messages

Conversation

@dejanzele
Copy link
Copy Markdown
Member

@dejanzele dejanzele commented May 5, 2026

Summary

pendingPodChecks.getAction in internal/executor/podchecks/event_checks.go iterates every event on a failing pod, calling getEventAction for each. Events that don't match any configured check return ("", ActionWait). The function appended those empty strings to the result list anyway, then strings.Join(..., "\n") produced multiple consecutive newlines.

End-user impact: when kubelet emits multiple events on a failing pod (Scheduled, Pulling, Failed, BackOff, etc.) and only one matches a check, the failure message that lands in lookoutdb.job_run.error ends up with several blank lines between the preface and the actual error text.

Fix

Skip empty messages before appending. One-line change.

if message != "" {
    resultMessages = append(resultMessages, message)
}

Empty strings are dead weight in a \n-joined list; nothing else relied on their presence.

Validation

Live impact: removes 4-6 spurious blank lines from the user-facing failure message in Lookout when k8s emits more than one event on the failing pod.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

Fixes spurious blank lines in pod failure messages by skipping empty strings before appending to the resultMessages slice in eventChecks.getAction. Previously, events that matched no configured check returned ("", ActionWait) and the empty string was unconditionally appended, causing strings.Join to produce `

` separators in the final user-facing error message.

  • event_checks.go: Adds a simple if message != "" guard before append, ensuring only non-empty per-event messages are included in the joined result.
  • event_checks_test.go: Adds Test_getAction_WhenSomeEventsMatch_OnlyMatchedMessagesAreIncluded, which drives four events through the checker (two Normal, two Warning, only one matching the configured rule) and asserts both correct action and absence of `

` in the output.

Confidence Score: 5/5

Safe to merge — the change is a minimal, well-targeted guard on an append call with no effect on the action-selection logic.

The fix touches a single append site, leaves maxAction accumulation and all return paths intact, and is accompanied by a new regression test that directly exercises the previously broken scenario. No existing tests are altered, and the new test covers both the action result and the absence of blank lines in the joined message.

No files require special attention.

Important Files Changed

Filename Overview
internal/executor/podchecks/event_checks.go One-line guard added to skip empty messages before appending to resultMessages, eliminating spurious blank lines in joined output
internal/executor/podchecks/event_checks_test.go New regression test added that sends mixed matching/non-matching events and asserts no blank lines and correct message content

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[getAction called with podEvents] --> B[Iterate each event]
    B --> C[getEventAction: check event against configured rules]
    C --> D{Event matches a rule AND past grace period?}
    D -- Yes --> E[return action, podEvent.Message]
    D -- No --> F[return ActionWait, empty string]
    E --> G[resultAction = maxAction]
    F --> G
    G --> H{message != empty?}
    H -- Yes --> I[append message to resultMessages]
    H -- No --> J[skip - previously caused blank lines]
    I --> K[Next event]
    J --> K
    K --> B
    B -- done --> L[strings.Join resultMessages with newline]
    L --> M[Return resultAction, joined message]
Loading

Reviews (4): Last reviewed commit: "Skip empty messages when aggregating pen..." | Re-trigger Greptile

@dejanzele dejanzele force-pushed the fix-podchecks-skip-empty-event-messages branch 2 times, most recently from 5148e14 to 0019b9b Compare May 5, 2026 22:49
Signed-off-by: Dejan Zele Pejchev <pejcev.dejan@gmail.com>
@dejanzele dejanzele force-pushed the fix-podchecks-skip-empty-event-messages branch from 0019b9b to 159c44d Compare May 5, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant