fix(controller): degrade scope not whole target on RBAC-forbidden namespace#28
Conversation
…amespace Per GUIDELINES.md §1 (ErrForbidden), a forbidden namespace within a target's scope must degrade that scope, not hard-fail the whole reconcile. KollectTarget previously flipped fully Degraded (removing Ready/Synced) whenever HasForbiddenScope was true, even though collection from allowed namespaces continued. Extract reconcileTargetReady's engine-derived signals into a pure applyTargetReadyState helper so the scope-degrade branch is directly unit-testable without standing up RBAC-restricted envtest fixtures. Ready now stays true on a forbidden scope; Synced carries the new ScopeForbidden reason/message and a Warning event is recorded. AccessCheckFailed (SAR API failure, a different error class) keeps hard-failing as before.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Review summary (gate matrix + analysis)
TDD: 3 new unit tests ( Functional correctness: One P3 observation, not blocking: if both No P0/P1 findings. I can't self-approve this (would defeat the review requirement) — flagging here for your review/approval on GitHub. |
…espace (#28) * 🐛 fix(controller): degrade scope not whole target on RBAC-forbidden namespace Per GUIDELINES.md §1 (ErrForbidden), a forbidden namespace within a target's scope must degrade that scope, not hard-fail the whole reconcile. KollectTarget previously flipped fully Degraded (removing Ready/Synced) whenever HasForbiddenScope was true, even though collection from allowed namespaces continued. Extract reconcileTargetReady's engine-derived signals into a pure applyTargetReadyState helper so the scope-degrade branch is directly unit-testable without standing up RBAC-restricted envtest fixtures. Ready now stays true on a forbidden scope; Synced carries the new ScopeForbidden reason/message and a Warning event is recorded. AccessCheckFailed (SAR API failure, a different error class) keeps hard-failing as before. * 📄 docs(changelog): sync scope-degrade fix entry
Summary
KollectTargetreconcile previously flipped fullyDegraded(removingReady/Synced) wheneverHasForbiddenScopewas true, even though collection from allowed namespaces continued — violatingGUIDELINES.md§1'sErrForbiddenrule ("degrade scope, never hard-fail the whole reconcile").reconcileTargetReady's engine-derived signals into a pureapplyTargetReadyStatehelper so the previously-untested forbidden-scope branch is directly unit-testable without standing up RBAC-restricted envtest fixtures.ReadystaysTrue,Degradedstays absent,Syncedcarries a newScopeForbiddenreason + message, and a Warning event is recorded.AccessCheckFailed(a different error class — SAR API failure) and sink-unreachable both keep the prior full-degrade behavior.Test plan
go build ./...task verify(no codegen drift)task lint/task arch-lint(0 issues)task test(full unit + envtest, race on)task coverage(79.0%, floor 72%)task scrub(clean)task changelog:verify