Emit Events from the three config controllers#5514
Open
ChrisJBurns wants to merge 2 commits into
Open
Conversation
The MCPOIDCConfig, MCPExternalAuthConfig, and MCPAuthzConfig controllers logged validation failures and deletion-blocked transitions but emitted no Kubernetes Events, so `kubectl describe` could not show why a policy-shaped config was rejected or which workloads blocked its deletion. Per the operator Status Condition Parity rule, all three siblings gain an EventRecorder in one change. Each reconciler now carries `Recorder events.EventRecorder`, wired in app.go, and emits: a Warning ConfigInvalid on entering the invalid state, a Warning DeletionBlocked on entering the blocked state, and a Normal ConfigValid on recovery. Emission is transition-gated (the prior condition is read before MutateAndPatchStatus mutates it in place) so steady-state reconciles produce no event spam. Messages carry only structural validation errors and logical workload names — never raw policy, secrets, tokens, or internal URLs. Closes #5496 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## cburns/migrate-sibling-controllers-mutatepatchstatus #5514 +/- ##
========================================================================================
+ Coverage 69.71% 69.75% +0.03%
========================================================================================
Files 645 646 +1
Lines 65616 65684 +68
========================================================================================
+ Hits 45745 45815 +70
Misses 16526 16526
+ Partials 3345 3343 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…nto cburns/config-controllers-eventrecorder
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
The
MCPOIDCConfig,MCPExternalAuthConfig, andMCPAuthzConfigcontrollers logged validation failures and deletion-blocked transitions but emitted no KubernetesEventobjects — so an operator runningkubectl describe mcpauthzconfig <name>(or the siblings) couldn't see why a config was rejected or which workloads were blocking its deletion. Per the operatorStatus Condition Parityrule, all three siblings gain anEventRecorderin a single change so the parity is established as one logical step. Flagged as F15 in the multi-agent review of #4777.Closes #5496
Medium level
config_controller_events.go):emitConfigEvent(nil-guardedEventfwrapper),emitConfigRecoveryEvent(NormalConfigValid, no-op unless recovering),conditionStatusIs(transition detection), and the sharedConfigInvalid/ConfigValid/DeletionBlockedevent reasons.Recorder events.EventRecorder, wired inapp.goviamgr.GetEventRecorder("<resource>-controller"), plus anevents.k8s.io/eventsRBAC marker (matching the five sibling controllers that already carry it; regenerated manifests show no diff since the permission was already granted).MutateAndPatchStatus(which mutates conditions in place), so a Warning fires only on entering the invalid/blocked state and the recovery Normal fires only on theFalse→Truetransition — steady-state reconciles produce no event spam.setInvalidpath, and both success paths (handleConfigHashChange,updateReferencingWorkloads) are all covered.err.Error()fromValidate()) and logical workloadKind/Namereferences — never raw policy, secrets, bearer tokens, or fully-qualified internal URLs. A test asserts the ExternalAuth deletion event omits the token URL and secret ref.Low level
cmd/thv-operator/controllers/config_controller_events.goemitConfigEvent,emitConfigRecoveryEvent,conditionStatusIs.cmd/thv-operator/controllers/mcpoidcconfig_controller.goRecorderfield + RBAC marker; emitConfigInvalid,ConfigValid,DeletionBlocked.cmd/thv-operator/controllers/mcpexternalauthconfig_controller.goRecorderfield + RBAC marker; emit on inline + OBO failure, both recovery paths, and deletion-block.cmd/thv-operator/controllers/mcpauthzconfig_controller.goRecorderfield + RBAC marker; emitConfigInvalid,ConfigValid,DeletionBlocked.cmd/thv-operator/app/app.goRecorderfor all three controllers.cmd/thv-operator/controllers/config_controller_events_test.goevents.NewFakeRecorder.Type of change
Test plan
task test(operatorcontrollers+appunit suites) passestask buildpassesgofmt+go vet ./cmd/thv-operator/...clean (localtask lint-fixblocked by a known golangci-lint go1.24/1.26 toolchain mismatch; CI lint is unaffected)ConfigInvalidon validation failure, NormalConfigValidon recovery (incl. the steady-state path), WarningDeletionBlockedwhen gated by a referencing workload, no event spam while staying invalid, nil-recorder safety, and that event messages don't leak the token URL / secret refSpecial notes for reviewers
events.k8s.ioRBAC markers were added for parity with the sibling controllers, buttask operator-manifestsproduces no diff — the aggregated role already grantedevents: create;patchfrom the existing five controllers.cmd/thv-operator/test-integration/...) was not run locally; it requires envtest control-plane binaries (/usr/local/kubebuilder/bin/etcd) that aren't installed in this environment.Generated with Claude Code