Skip to content

Fix empty action field on IRI-mapped events#1500

Merged
friegger merged 3 commits into
mainfrom
fix/1489-ensure-events-action-field-is-set
Jul 6, 2026
Merged

Fix empty action field on IRI-mapped events#1500
friegger merged 3 commits into
mainfrom
fix/1489-ensure-events-action-field-is-set

Conversation

@friegger

@friegger friegger commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The events.k8s.io/v1 API server rejects events with an empty action field. Providers do not always populate Spec.Action on IRI events, causing the poollet event mappers to push invalid events. Fall back to Spec.Reason when Spec.Action is empty.

Additional changes will update provider-utils and providers to correctly send the action field.

Contributes to #1489

Summary by CodeRabbit

  • Bug Fixes
    • Ensured emitted Kubernetes events always have a non-empty action value.
    • When the source event action is empty, Kubernetes event action now defaults to Unknown.
    • Applied consistently to bucket, machine, and volume event reporting.
    • Added automated tests confirming Kubernetes Reason, Message, and Type are preserved while Action is set to Unknown when the source action is empty.

@friegger friegger requested a review from a team as a code owner July 3, 2026 09:25
@github-actions github-actions Bot added size/L bug Something isn't working labels Jul 3, 2026
@friegger friegger requested a review from lukasfrank July 3, 2026 09:25
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c09093f7-afee-499a-a6d3-349d01f6eccc

📥 Commits

Reviewing files that changed from the base of the PR and between 77bb0c1 and 2702d8f.

📒 Files selected for processing (6)
  • poollet/bucketpoollet/bem/bem.go
  • poollet/bucketpoollet/bem/bem_test.go
  • poollet/machinepoollet/mem/mem.go
  • poollet/machinepoollet/mem/mem_test.go
  • poollet/volumepoollet/vem/vem.go
  • poollet/volumepoollet/vem/vem_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • poollet/bucketpoollet/bem/bem.go

📝 Walkthrough

Walkthrough

Bucket, machine, and volume event mappers now ensure Kubernetes event actions are non-empty by substituting Unknown when Spec.Action is empty. Tests were added for each mapper to verify the emitted event fields.

Changes

Event action fallback fix

Layer / File(s) Summary
Bucket event mapper action fallback
poollet/bucketpoollet/bem/bem.go, poollet/bucketpoollet/bem/bem_test.go
relist computes action from Spec.Action or Unknown before calling Eventf; a new test asserts the emitted event's Action becomes Unknown when Action is empty.
Machine event mapper action fallback
poollet/machinepoollet/mem/mem.go, poollet/machinepoollet/mem/mem_test.go
relist computes action from Spec.Action or Unknown before calling Eventf; a new test asserts the same fallback behavior for machine events.
Volume event mapper action fallback
poollet/volumepoollet/vem/vem.go, poollet/volumepoollet/vem/vem_test.go
relist computes action from Spec.Action or Unknown before calling Eventf; a new test asserts the same fallback behavior for volume events.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description does not follow the required template and is missing the three proposed-change bullets and a proper Fixes # reference. Add a # Proposed Changes section with three bullet items and replace Contributes #1489 with a Fixes # reference.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main fix: handling empty action values in IRI-mapped events.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/1489-ensure-events-action-field-is-set

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
poollet/bucketpoollet/bem/bem.go (1)

56-63: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider extracting the action-fallback logic to a shared helper.

The identical 4-line fallback (action := Spec.Action; if action == "" { action = Spec.Reason }) is duplicated verbatim in mem.go and vem.go. A small shared helper (e.g., eventutils.ResolveAction(action, reason string) string) would avoid drift if the fallback logic needs to change later.

Also note: if both Spec.Action and Spec.Reason are empty, action remains empty and the event could still be rejected by events.k8s.io/v1. This appears to be accepted as out-of-scope per the PR description (follow-up planned for provider-utils/providers), so just flagging for awareness.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@poollet/bucketpoollet/bem/bem.go` around lines 56 - 63, The action fallback
logic in the event emission path is duplicated across bem, mem, and vem, so
extract the repeated Spec.Action/Spec.Reason handling into a shared helper such
as eventutils.ResolveAction(action, reason string) string. Update the Eventf
call sites in the relevant event builders to use that helper instead of inlining
the fallback, keeping the behavior unchanged for now and preserving the existing
acceptance of empty action as out of scope.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@poollet/bucketpoollet/bem/bem.go`:
- Around line 56-63: The action fallback logic in the event emission path is
duplicated across bem, mem, and vem, so extract the repeated
Spec.Action/Spec.Reason handling into a shared helper such as
eventutils.ResolveAction(action, reason string) string. Update the Eventf call
sites in the relevant event builders to use that helper instead of inlining the
fallback, keeping the behavior unchanged for now and preserving the existing
acceptance of empty action as out of scope.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0942a1ec-f61f-420b-bbef-f9c643fa2bd6

📥 Commits

Reviewing files that changed from the base of the PR and between fd1f73f and ef8b149.

📒 Files selected for processing (6)
  • poollet/bucketpoollet/bem/bem.go
  • poollet/bucketpoollet/bem/bem_test.go
  • poollet/machinepoollet/mem/mem.go
  • poollet/machinepoollet/mem/mem_test.go
  • poollet/volumepoollet/vem/vem.go
  • poollet/volumepoollet/vem/vem_test.go

The events.k8s.io/v1 API server rejects events with an empty action field.
Providers do not always populate Spec.Action on IRI events, causing the
poollet event mappers to push invalid events. Fall back to Spec.Reason
when Spec.Action is empty.

Contributes to #1489

Signed-off-by: Felix Riegger <felix.riegger@sap.com>
@friegger friegger force-pushed the fix/1489-ensure-events-action-field-is-set branch from ef8b149 to bd2d47f Compare July 3, 2026 10:04
@friegger friegger linked an issue Jul 3, 2026 that may be closed by this pull request
3 tasks
@lukasfrank

Copy link
Copy Markdown
Member

What should happen if Action and Reason are empty strings?

Works also, if there is nor Reason. It also
makes it obvious, if we miss to change the sources
to send a proper Action.

Signed-off-by: Felix Riegger <felix.riegger@sap.com>
@friegger

friegger commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

What should happen if Action and Reason are empty strings?

Good point, changed the implementation to fallback to Unknown, if the Action is missing.

@friegger friegger merged commit a0e22c5 into main Jul 6, 2026
12 checks passed
@friegger friegger deleted the fix/1489-ensure-events-action-field-is-set branch July 6, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Event Handling has to be updated after breaking change in controller-runtime

2 participants