Skip to content

✨ Add admission response status code metrics for webhooks#3534

Open
mattsu2020 wants to merge 5 commits into
kubernetes-sigs:mainfrom
mattsu2020:2972
Open

✨ Add admission response status code metrics for webhooks#3534
mattsu2020 wants to merge 5 commits into
kubernetes-sigs:mainfrom
mattsu2020:2972

Conversation

@mattsu2020

Copy link
Copy Markdown
Contributor

What does this do, and why do we need it?

This PR adds an admission-response-level metric:

controller_runtime_webhook_admission_responses_total{webhook,allowed,admission_code}

This PR intentionally does not change the HTTP response status for valid AdmissionReview responses. Kubernetes admission webhooks are expected to return HTTP 200 with an AdmissionReview body, including when an admission decision is denied.

The existing controller_runtime_webhook_requests_total{code=...} metric continues to represent the HTTP transport status code observed by promhttp. The new metric separately exposes AdmissionResponse.status.code, making admission decisions and errors such as 400, 403, 429, and 500 observable without changing the existing HTTP request metric semantics.

The common response series are initialized when an Admission webhook is registered directly with the webhook server or configured through StandaloneWebhook. Responses with an unset status code follow the existing Response.Complete behavior and are recorded as 200.

Validation

  • go test ./pkg/webhook/...
  • go vet ./pkg/webhook/...

Addresses the metrics aspect of #2972.

@kubernetes-prow kubernetes-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 22, 2026
@kubernetes-prow

Copy link
Copy Markdown
Contributor

Hi @mattsu2020. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 kubernetes-sigs/prow repository.

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mattsu2020
Once this PR has been reviewed and has the lgtm label, please assign vincepri for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@kubernetes-prow kubernetes-prow Bot requested review from troy0820 and vincepri June 22, 2026 22:35
@kubernetes-prow kubernetes-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 22, 2026
@mattsu2020 mattsu2020 marked this pull request as ready for review June 22, 2026 23:22
@kubernetes-prow kubernetes-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 22, 2026
@k8s-triage-robot

Copy link
Copy Markdown

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 23, 2026
@mattsu2020

Copy link
Copy Markdown
Contributor Author

Hi @vincepri @troy0820,
Could you please take a look at this PR when you have a chance?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants