feat(controller): migrate Instance event emission to the supported events API#178
Draft
scotwells wants to merge 1 commit into
Draft
feat(controller): migrate Instance event emission to the supported events API#178scotwells wants to merge 1 commit into
scotwells wants to merge 1 commit into
Conversation
0701ff4 to
f66cf23
Compare
…ents API The InstanceReconciler emitted quota and referenced-data events through the deprecated core/v1 event recorder. Move to the events.k8s.io/v1 recorder so Instance events keep flowing on the supported API surface, with each event now carrying a machine-readable action (the controller operation) alongside its existing reason (the outcome). Operators see the same Warning/Normal events in `kubectl describe instance`, now backed by events.k8s.io. All emit sites funnel through the emitEvent helper, which passes the message as a "%s" argument so backend error text containing a literal '%' is not format-expanded, and truncates the note to the 1024-character server-side limit so oversized notes are not silently rejected. The controller RBAC role is regenerated to grant events.k8s.io instead of the core events group. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
f66cf23 to
6e90009
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When an Instance won't schedule — project quota exhausted, no budget configured, project misconfigured — operators find out why by reading the Kubernetes Events on the Instance (
kubectl describe instance). That quota-failure observability was added in #118 and is now part of how operators self-diagnose.That emission was wired through controller-runtime's deprecated event recorder, an API slated for removal. Left as-is, a routine dependency bump could have silently broken event emission — or the build — quietly degrading the diagnostics operators depend on. This moves Instance event emission onto the supported Kubernetes events API (
events.k8s.io) so that visibility keeps working through future dependency upgrades.Two user-visible wins come with the new API:
action— what the controller was doing (claiming quota, releasing quota, resolving referenced data, removing the scheduling gate) — alongside the existingreason(what happened). Reasons stay the outcome; actions name the operation.All existing event reasons and messages are unchanged, so nothing operators already rely on breaks —
kubectl describe instanceshows the same Warning/Normal events, now backed byevents.k8s.io.What changed
record.EventRecordertoevents.EventRecorder, and removed the//nolint:staticchecksuppression the earlier deferral left behind.actionconstants; reason codes and human-readable messages pass through byte-identical.%in backend error text can't be mis-rendered.events.k8s.io(create/patch).action/reasonfields the stock fake discards.Notes for reviewers / deployers
events.k8s.iocreate/patch grant, which ships in this PR'srole.yaml. envtest runs as admin, so a missing grant in a deployment overlay would be silent in CI — worth confirming events actually land on a live cell during lab verification, and that any overlay mirroring the controller role carries theevents.k8s.iorule.core/v1Events specifically (rather thankubectl/describe, which surface both APIs) would no longer see these events. Low risk — no such in-repo consumer was found — flagged for awareness.Closes #119.
🤖 Generated with Claude Code