-
Notifications
You must be signed in to change notification settings - Fork 40.9k
feat: deduplicate validation errors and increment metric #132613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: deduplicate validation errors and increment metric #132613
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
Hi @gavinkflam. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
This PR may require stable metrics review. Stable metrics are guaranteed to not change. Please review the documentation for the requirements and lifecycle of stable metrics and ensure that your metrics meet these guidelines. |
Signed-off-by: Gavin Lam <[email protected]>
1fced79
to
fd84973
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gavinkflam The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Changed the metric to alpha according to KEP-1209. |
// and increment duplicate validation error metric when duplicates are found. | ||
func DeduplicateValidationErrorsAndUpdateMetric(qualifiedKind schema.GroupKind, operation string, errs field.ErrorList) field.ErrorList { | ||
uniqueErrs := field.ErrorList{} | ||
errsSet := sets.New[string]() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given how few errors there are, we should just make([]string, 0, len(errs))
, do slices.Contains()
for lookup, and append to the list if it is not found.
@@ -52,6 +53,15 @@ var validationMetricsInstance = &validationMetrics{ | |||
StabilityLevel: metrics.BETA, | |||
}, | |||
), | |||
DuplicateValidationErrorCounter: metrics.NewCounterVec( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpbetz -- does this need a KEP?
What type of PR is this?
/kind feature
What this PR does / why we need it:
Several resources currently emit duplicate validation errors during update operations. This results in bloated and confusing API responses and redundant processing. I've submitted a few PRs to address specific cases, but there are likely many more instances still present in the codebase.
Detecting these duplicates is challenging because kubectl deduplicates error messages before displaying them to the user and hiding the issue.
This PR introduces server-side deduplication of validation errors before the response is returned. This helps produce cleaner, more concise responses and reduces unnecessary payload size. Additionally, a new metric is introduced to track the number of duplicate errors detected, providing visibility into remaining problem areas and helping to identify opportunities for further cleanup.
Which issue(s) this PR is related to:
Fixes #130656
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: