🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@lalitc375
Copy link
Contributor

@lalitc375 lalitc375 commented Dec 11, 2025

What type of PR is this?
/kind bug

What this PR does / why we need it

This PR refactors the metricIdentifier function in pkg/registry/rest/validate.go to reliably determine the resource kind by using the scheme. This is necessary because the previous implementation, which relied on obj.GetObjectKind().GroupVersionKind(), could be unreliable for internal objects where the API version and kind are not always populated on the object itself. The scheme, however, is the authoritative source for this information.

This change ensures that we can accurately identify the resource kind, which is crucial for the correctness of our validation metrics.

This PR addresses this by:

  • Passing the *runtime.Scheme to the metricIdentifier function.
  • Using scheme.ObjectKinds(obj) to reliably determine the kind of the object.

The unit tests in pkg/registry/rest/validate_test.go have been updated to reflect this change.

Fixes

This PR fixes the following validation discrepancies by ensuring the resource kind is correctly identified:

# HELP apiserver_validation_declarative_validation_parity_discrepancies_total [ALPHA] Number of discrepancies between declarative and handwritten validation, broken down by validation identifier.
# TYPE apiserver_validation_declarative_validation_parity_discrepancies_total counter
apiserver_validation_declarative_validation_parity_discrepancies_total{validation_identifier="unknown_resource_approval_update"} 2
apiserver_validation_declarative_validation_parity_discrepancies_total{validation_identifier="unknown_resource_status_update"} 2

Special notes for your reviewer

None

Does this PR introduce a user-facing change?

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Dec 11, 2025
@k8s-ci-robot
Copy link
Contributor

Please note that we're already in Test Freeze for the release-1.35 branch. This means every merged PR will be automatically fast-forwarded via the periodic ci-fast-forward job to the release branch of the upcoming v1.35.0 release.

Fast forwards are scheduled to happen every 6 hours, whereas the most recent run was: Thu Dec 11 03:43:56 UTC 2025.

@k8s-ci-robot k8s-ci-robot added do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Dec 11, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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.

@k8s-ci-robot k8s-ci-robot added needs-priority Indicates a PR lacks a `priority/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 11, 2025
@lalitc375
Copy link
Contributor Author

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added area/apiserver sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Dec 11, 2025
@lalitc375
Copy link
Contributor Author

/assign @jpbetz

The metricIdentifier function in pkg/registry/rest/validate.go has been updated to consistently use  for determining the resource kind. This change ensures that the identifier is derived from the scheme, which is the authoritative source for API type information.

Corresponding unit tests in pkg/registry/rest/validate_test.go have been updated to align with this new behavior, explicitly passing the scheme in test cases where kind resolution is expected and verifying the correct unknown_resource fallback when the scheme or object is not sufficient to determine the kind.
@lalitc375 lalitc375 force-pushed the fix-validation-identifier branch from 13d4aec to 391045e Compare December 11, 2025 20:53
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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

Labels

area/apiserver cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants