Skip to content

Add script to verify feature gates cleanup #131712

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

simoncampion
Copy link

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Feature gate code that has been locked to default at version X.Y is required to stay in the code base until version X.Y+3 for version emulation, but can be cleaned up afterwards. This commit adds a script checking whether any feature gates require cleanup. It is intended to be run as a release-blocking test.

Which issue(s) this PR fixes:

Fixes #130759

Special notes for your reviewer:

There are a few things I need your input on:

  • Are there defined requirements for feature gate cleanup across major versions? Currently, the script errors if the current major version differs from the major version at which a feature gate was locked.

  • The issue requires that this script is run in a release-blocking test. So, we need to run make verify WHAT=featuregates-cleanup in release pipelines. Should I open a PR to add a new job here once this PR is merged? I'm unsure that's the right place because all jobs there are E2E tests.

  • The script depends on yq. As far as I see, some but not all CI images include yq. Is it okay to depend on yq? If not, it'd be possible to do the YAML parsing in pure Bash, but that'd be brittle and hard to maintain. Instead, in that case, I'd suggest I rewrite the script in Python, or add the logic to the existing compatibility_lifecycle tool, like this:

    go run test/compatibility_lifecycle/main.go feature-gates verify-cleanup
    

Thanks for your help!

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 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-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 11, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @simoncampion. 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 /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. Regular contributors should join the org to skip this step.

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.

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 the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label May 11, 2025
@simoncampion
Copy link
Author

/sig api-machinery
/cc @siyuanfoundation

@k8s-ci-robot k8s-ci-robot added 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 May 11, 2025
@siyuanfoundation
Copy link
Contributor

siyuanfoundation commented May 13, 2025

thank you @simoncampion for raising the PR!
I am think more like adding a new flag in test/compatibility_lifecycle invoking a function similar to verifyFeatureRemoval instead of using shell script directly to parse the yaml file, so that every verification about compatibility version are in one place. Does it make sense to you?

Feature gate code that has been locked to default at version X.Y can be
cleaned up at version X.Y+4. This commit adds a script that verifies
that such unnecessary feature gate code was cleaned up. It is intended
to be run as a release-blocking test.
@simoncampion simoncampion force-pushed the featuregates-cleanup branch from d062aad to b5bc58c Compare May 14, 2025 19:28
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: simoncampion
Once this PR has been reviewed and has the lgtm label, please assign liggitt for approval. 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

@k8s-ci-robot k8s-ci-robot added area/test sig/testing Categorizes an issue or PR as relevant to SIG Testing. labels May 14, 2025
@simoncampion
Copy link
Author

I am think more like adding a new flag in test/compatibility_lifecycle invoking a function similar to verifyFeatureRemoval instead of using shell script directly to parse the yaml file, so that every verification about compatibility version are in one place. Does it make sense to you?

Makes sense 👍 I removed the logic in the script and instead implemented the check in test/compability_lifecycle.

@@ -266,6 +291,52 @@ func verifyFeatureRemoval(featureList []featureInfo, baseFeatureList []featureIn
return nil
}

// getFeaturesAndVerifyCleanup gets the feature list from the code base and verifies that
// no feature gates need to be cleaned up.
func getFeaturesAndVerifyCleanup(rootPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

since this command will only be run in CI, I think we can just use the yaml file to get features.

Copy link
Author

Choose a reason for hiding this comment

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

I see. I changed it to get features from the YAML file.

@Jefftree
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Jun 16, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 16, 2025
@simoncampion simoncampion changed the title [WIP] Add script to verify feature gates cleanup Add script to verify feature gates cleanup Jun 29, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 29, 2025
@simoncampion
Copy link
Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/test 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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. sig/testing Categorizes an issue or PR as relevant to SIG Testing. 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.

[Compatibility Version] add verify test to ensure old feature gate are cleaned up after N releases.
4 participants