Skip to content

Migrate to declarative validation: ReplicationController/scale spec.replicas field #131664

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

Merged
merged 16 commits into from
May 27, 2025

Conversation

jpbetz
Copy link
Contributor

@jpbetz jpbetz commented May 8, 2025

What type of PR is this?

/kind feature

What this PR does / why we need it:

Migrates the ReplicationController's scale subresource to declarative validation.

Adds:

  • +k8s:supportsSubresource (used to declare that the validation on a type also supports validation of a "status type subresource" subresource of that type)
  • +k8s:isSubresource (used to declare that the validation on a type IS for a specific "scale type subresource")

Example usages:

To allow a subresource to be validated by root resource, add it as a supportedSubresource. For example, to allow the ReplicationController to validate both the scale and status subresource, use:

// +k8s:supportsSubresource=/scale
// +k8s:supportsSubresource=/status

// ReplicationController...
type ReplicationController struct { ... }

To identify a type as a subresource kind, mark it with isSubresource. For example:

// +k8s:isSubresource=/scale

// Scale ...
type Scale struct { ... }

Special notes for your reviewer:

Does this PR introduce a user-facing change?

The validation of `replicas` field in the ReplicationController `/scale` subresource has been migrated to declarative validation.
If the `DeclarativeValidation` feature gate is enabled, mismatches with existing validation are reported via metrics.
If the `DeclarativeValidationTakeover` feature gate is enabled, declarative validation is the primary source of errors for migrated fields.

/sig api-machinery

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 8, 2025
@jpbetz jpbetz changed the title Enable validation-gen for scale group-versions Migrate to declarative validation: ReplicationController/scale spec.replicas field May 8, 2025
@k8s-ci-robot k8s-ci-robot added kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API sig/apps Categorizes an issue or PR as relevant to SIG Apps. labels May 8, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in SIG Apps May 8, 2025
@jpbetz
Copy link
Contributor Author

jpbetz commented May 8, 2025

/assign @deads2k

This is best reviewed commit-by-commit. xref #130725 for how we already validate the same field on the root resource with declarative validation.

cc @thockin @aaron-prindle @yongruilin

@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@aaron-prindle
Copy link
Contributor

/triage approved

@k8s-ci-robot
Copy link
Contributor

@aaron-prindle: The label(s) triage/approved cannot be applied, because the repository doesn't have them.

In response to this:

/triage approved

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.

@aaron-prindle
Copy link
Contributor

/triage accepted

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels May 8, 2025
@jpbetz jpbetz force-pushed the subresources-enable-replicas branch 2 times, most recently from 0731ff2 to 8b75cdc Compare May 9, 2025 15:29
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2025
@jpbetz
Copy link
Contributor Author

jpbetz commented May 9, 2025

/test pull-kubernetes-e2e-kind-alpha-features
/test pull-kubernetes-e2e-kind-beta-features
/test pull-kubernetes-e2e-kind-alpha-beta-features

@jpbetz jpbetz force-pushed the subresources-enable-replicas branch from 8b75cdc to 20bfb66 Compare May 9, 2025 21:16
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 9, 2025
@jpbetz jpbetz force-pushed the subresources-enable-replicas branch from 06f0352 to 81a0757 Compare May 24, 2025 02:02
@jpbetz
Copy link
Contributor Author

jpbetz commented May 24, 2025

Rebased and squashed.

@jpbetz
Copy link
Contributor Author

jpbetz commented May 24, 2025

/retest

Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to send this comment before - not sure how I missed it.

@jpbetz jpbetz force-pushed the subresources-enable-replicas branch from 81a0757 to 1d17ca9 Compare May 24, 2025 04:03
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels May 24, 2025
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

/lgtm
/approve

/hold - does @deads2k want a last look?

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels May 25, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 20a4262d166730b83c9df3a56e03c02b39f67514

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jpbetz, thockin

The full list of commands accepted by this bot can be found here.

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 25, 2025
@jpbetz
Copy link
Contributor Author

jpbetz commented May 27, 2025

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 27, 2025
@jpbetz
Copy link
Contributor Author

jpbetz commented May 27, 2025

/retest

@k8s-ci-robot k8s-ci-robot merged commit 1449265 into kubernetes:master May 27, 2025
14 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.34 milestone May 27, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Done in SIG Apps May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/apiserver area/code-generation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/apps Categorizes an issue or PR as relevant to SIG Apps. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants