MULTIARCH-6087: Migrate operand events to native events/v1 #776
@AnnaZivkovic: This pull request references MULTIARCH-6087 which is a valid jira issue.
Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.1.0" version, but no target version was set.
<details>
In response to this:
>## Summary
>Split MULTIARCH-6087 out of #773 so the native Kubernetes events migration can merge independently, before the Go version/dependency bump.
>- Add shared native events.k8s.io/v1 recorder infrastructure and structured test capture.>- Migrate pod-placement controller/webhook, CEL, and ENoExec operand event producers; preserve reasons/messages and add semantic actions.
>- Own recorder and delayed-webhook-job lifetimes, with producer shutdown before recorder cleanup.
>- Grant native event create/patch/update permissions in runtime roles and generated operator RBAC/bundle manifests.
>- Update native event queries and assertions, including core/v1 compatibility coverage.
>## Scope and independence
>Five commits cherry-picked unchanged from #773 (git range-diff confirms identical patches):>1.
20a9ee67 → 28341904: recorder infrastructure>2.
9026e5a9 → 43775c71: operand migration and producer lifetimes>3.
c4f29928 → 1c125c18: RBAC>4.
e263c0f7 → 54fa7c39: native publication/compatibility assertions>5.
484e00c3 → 1aa3538c: migration design and historical verification notes>Based directly on upstreammain(42f9d7e6). Go remains 1.26.7;go.mod,go.sum, andvendor/are unchanged. Required client-go APIs already exist in this dependency set. No dependency updater, Go bump, Konflux removal, or unrelated CPPC fixes included. #773 remains unchanged and will need cleanup/rebase after this merges.
>## Verification on this standalone branch
>- [x] Go 1.26.7, CGO_ENABLED=1, vendored dependencies.>- [x] Race-enabled unit tests across
pkg/events, pkg/models, pkg/testing/framework, cmd, operator, pod-placement, and ENoExec handler packages (-run '^Test' -skip '^Test(APIs|Operator)$').>- [x] Race-enabled focused pod-placement envtest:
publishes a gate event, using Kubernetes 1.36.2 assets; verifies native publication and core/v1 conversion.>- [x]
git diff --check; dependency files/vendor identical to base; all five patches unchanged.>- [ ] Full test/build/lint pipeline and deployed-cluster E2E not run to completion. Initial broader test invocation timed out; focused runs above completed successfully.
>Historical execution notes in the cherry-picked docs describe original development verification, not additional checks performed on this split branch. Native event delivery remains best effort; aggregation may coalesce diagnostic notes.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.
</details>
Review pass on MULTIARCH-6087 (native events.k8s.io/v1 migration). I also re-verified the PR's own claims: the five patches are byte-identical to #773 (git range-diff + patch diff), go.mod/go.sum/vendor/ are unchanged from base, and go test ./pkg/events plus go vet on the touched non-cgo packages pass.
What this change does: the three operand binaries (pod-placement controller, gate webhook, ENoExec) stop writing core/v1 events and write native events.k8s.io/v1 events through a new shared recorder in pkg/events, each with a machine-readable action. It also takes ownership of two background lifetimes that used to leak (the recorder broadcaster and the webhook's delayed gate-event jobs) and drains producers before the recorder stops.
The design is sound. Shutdown ordering checks out against sync.WaitGroup usage in delayedSchedulingGatedEvent/ShutdownEventJobs, watch.Broadcaster.Action returning an error (not panicking) after shutdown, and MultiPool.ReleaseContext being a single 30s budget rather than 16x30s. events/v1 shares etcd storage with core/v1 (pkg/registry/events/rest/storage_events.go reuses pkg/registry/core/event/storage), so kubectl describe and other core/v1 readers keep working - the visibility regression I looked for does not exist.
One finding that is outside the diff, so it lands here instead of inline:
Alert runbook command is broken - docs/alerts/enoexec-alert.md:23
The ENoExec runbook tells on-call to run kubectl get events --field-selector involvedObject.kind=Pod,reportingController=multiarch-tuning-operator. reportingController is not a supported field-selector key on core/v1 events; the apiserver (see pkg/registry/core/event/strategy.go) exposes reportingComponent, mapped to Event.ReportingController. So the request is rejected with "field label not supported" and this command has never returned events. Since this PR is what decides which reporter field is set, please fix it here: kubectl get events -A --field-selector reportingComponent=multiarch-tuning-operator (optionally add reason=ExecFormatError), verified once on a real cluster.
Inline comments below cover the rest. Nothing here is a blocker on the core migration logic.
Minor: the action vocabulary is inconsistent in two places, which matters because the point of this change is queryable action values.
ArchitectureAwareGatedPodIgnored is tagged SchedulingGateRemove, but ignoring a pod is not a gate removal.NoSupportedArchitecturesFound gets ImageArchitectureCheck while ImageArchitectureInspectionError gets ImageInspectionFailed, so one inspection outcome is named after the check and the other after the failure.Suggestion: pick one rule (one action per reason is the easiest to reason about) and document it in a comment on this block, so future contributors do not invent a third convention.
ants.Release() releases the package-level default pool, which this code never uses - the webhook runs an ants.MultiPool, and handler.ShutdownEventJobs already calls ReleaseTimeout on it. This call does nothing (it was carried over from the previous cleanup block). Suggest deleting the line.
The webhook builds its event-job context from context.Background() even though RunClusterPodPlacementConfigOperandWebHook(ctx, mgr) already holds the recorder's recordingCtx and could pass it in.
Today the only thing preventing an in-flight gate event from publishing after broadcaster.Shutdown() is the order of the funcs returned from the constructor in cmd/main.go. That is correct right now, but it is an invisible coupling: an early return []func(){cleanup}, err added later would silently break it, and a post-shutdown publish is dropped with no error surfaced to the caller.
Suggest deriving eventJobsCtx from the passed ctx so the two lifetimes are linked structurally instead of by list order.
This test mostly exercises sync.Once (concurrent ShutdownEventJobs callers return the stored result) rather than the drain logic. TestWebhookEventJobsAdmissionShutdownRace above already covers the interesting concurrency case - 32 submitters racing shutdown. Suggest keeping that one and dropping this, unless you specifically want to pin the sync.Once contract.
Question on repo content rather than code: this file (and the plan document next to it) are agent-session artifacts - "design draft for approval", task checklists, historical verification notes. They are already out of date relative to the merged code.
The repo's convention for design documents is docs/enhancements/MTO-000N.md, and the rest of this material belongs in the PR description or the Jira issue. Suggest either dropping both files or rewriting the durable parts as docs/enhancements/MTO-0006-*.md. Currently this adds 375 lines that contradict the code they describe.
Same point as on the design document: this is a working plan for a specific agent workflow (superpowers:subagent-driven-development), not repository documentation. It ships instructions to "agentic workers" and a task checklist that no longer matches the branch. Suggest removing it from the tree and keeping the rationale in the PR/Jira.
/retest
/test ocp416-e2e-aws
/test ocp420-e2e-aws
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED
This pull-request has been approved by: <a href="https://github.com/outrigger-project/multiarch-tuning-operator/pull/776#" title="Author self-approved">AnnaZivkovic</a>, <a href="https://github.com/outrigger-project/multiarch-tuning-operator/pull/776#issuecomment-6746471157" title="LGTM">jcpowermac</a>
The full list of commands accepted by this bot can be found here.
The pull request process is described here
<details >
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
</details>
<!-- META={"approvers":[]} -->
/test unit
/test ocp418-e2e-azure
jcpowermac
AnnaZivkovic
Summary
Split MULTIARCH-6087 out of #773 so the native Kubernetes events migration can merge independently, before the Go version/dependency bump.
events.k8s.io/v1recorder infrastructure and structured test capture.Scope and independence
Five commits cherry-picked unchanged from #773 (
git range-diffconfirms identical patches):1.
20a9ee67→28341904: recorder infrastructure2.
9026e5a9→43775c71: operand migration and producer lifetimes3.
c4f29928→1c125c18: RBAC4.
e263c0f7→54fa7c39: native publication/compatibility assertions5.
484e00c3→1aa3538c: migration design and historical verification notesBased directly on upstream
main(42f9d7e6). Go remains 1.26.7;go.mod,go.sum, andvendor/are unchanged. Required client-go APIs already exist in this dependency set. No dependency updater, Go bump, Konflux removal, or unrelated CPPC fixes included. #773 remains unchanged and will need cleanup/rebase after this merges.Verification on this standalone branch
CGO_ENABLED=1, vendored dependencies.pkg/events,pkg/models,pkg/testing/framework,cmd, operator, pod-placement, and ENoExec handler packages (-run '^Test' -skip '^Test(APIs|Operator)$').publishes a gate event, using Kubernetes 1.36.2 assets; verifies native publication and core/v1 conversion.git diff --check; dependency files/vendor identical to base; all five patches unchanged.Historical execution notes in the cherry-picked docs describe original development verification, not additional checks performed on this split branch. Native event delivery remains best effort; aggregation may coalesce diagnostic notes.