CP-44602: Distinguish RBAC failure from a missing VWC in anaximander webhook config collection#908
CP-44602: Distinguish RBAC failure from a missing VWC in anaximander webhook config collection#908evan-cz wants to merge 1 commit into
Conversation
783916b to
b6acdd8
Compare
Greptile SummaryThis PR refactors the
Confidence Score: 5/5This is a diagnostic-script-only change with no impact on production control paths; the logic is well-reasoned and the The change is confined to a single diagnostic script section. The No files require special attention beyond the minor temp-file cleanup gap in Important Files Changed
Reviews (3): Last reviewed commit: "CP-44602: Distinguish RBAC failure from ..." | Re-trigger Greptile |
…ig collection anaximander reported "No ValidatingWebhookConfigurations found" whenever the cluster-scoped list failed -- for example when the collecting user lacks permission on validatingwebhookconfigurations -- because the error was swallowed with "2>/dev/null || echo """. That produced a misleading "the webhook receives no traffic" conclusion even when the webhook was working normally. Capture the kubectl exit status and, on failure, emit a warning that this is a permissions or API limitation rather than proof the webhook is unconfigured. Match the webhook config by chart label first, then by any webhook entry whose service is in the agent namespace (not just the first entry), and read the caBundle from the first non-empty entry. Only report a genuine absence when the listing succeeds and returns nothing. Verified: bash -n passes; fixtures for label-not-first, service-only, genuine absence, and a Forbidden error are all classified correctly. Co-Authored-By: Claude opus-4.8 <noreply@anthropic.com>
|
@greptile review |
b6acdd8 to
92cb828
Compare
Problem
The
webhook-config.txtsection ofanaximander.shreports "No ValidatingWebhookConfigurations found referencing namespace ..." whenever the cluster-scoped listing fails — for example when the collecting user lacks list permission onvalidatingwebhookconfigurations. The error was swallowed with2>/dev/null || echo "", so a permission denial looked identical to a genuine absence, and the script then printed a definitive "the API server is not configured to send admission requests" conclusion — a false negative on a perfectly healthy deployment.Two secondary weaknesses in the same block:
webhooks[0]and only service-based clientConfig, so it could miss the config or be tripped up by other controllers' webhook configurations in the cluster.webhooks[0]specifically.Change
app.kubernetes.io/part-of=cloudzero-agent) first, then fall back to any webhook entry whose service is in the agent namespace (jq-based, tolerant of other controllers' configs).Verification
bash -npasses; behavioral fixtures for label-not-first, service-only, genuine absence, aForbiddenerror, and a kubectl-warning-on-success (valid JSON) case are all classified correctly.This PR was created with AI assistance (Claude Code by Anthropic).