OCPBUGS-78594: reject feature gate lists when FeatureSet is empty#6367
Conversation
When FeatureSet is empty but customNoUpgrade or specialHandlingSupportExceptionRequired lists are populated, ToApiserverArgs() applies the features to kube-apiserver without creating an upgrade lock file. This means custom feature gates get applied without upgrade protection. Restore the validation check that rejects this configuration to prevent users from accidentally running unprotected custom feature gates. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> pre-commit.check-secrets: ENABLED
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a validation in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.11.3)level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: inconsistent vendoring in :\n\tgithub.com/apparentlymart/go-cidr@v1.1.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/coreos/go-systemd@v0.0.0-20190321100706-95778dfbb74e: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/google/go-cmp@v0.7.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/miekg/dns@v1.1.63: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/openshift/api@v0.0.0-20260309155933-45fd88d185dd: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/openshift/build-machinery-go@v0.0.0-20251023084048-5d77c1a5e5af: is explicitly required in go.mod, but not marked as explicit ... [truncated 29518 characters] ... belet: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/metrics: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/mount-utils: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/pod-security-admission: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/sample-apiserver: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/sample-cli-plugin: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\tk8s.io/sample-controller: is replaced in go.mod, but not marked as replaced in vendor/modules.txt\n\n\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo sync the vendor directory, run:\n\t\tgo mod vendor\n" Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/config/config_test.go (1)
822-831: Add a sibling test forspecialHandlingSupportExceptionRequiredwith emptyFeatureSet.This case now validates
CustomNoUpgrade, but the new rule also coversSpecialHandlingSupportExceptionRequired; adding that explicit case will better protect against regressions in that branch.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/config/config_test.go` around lines 822 - 831, Add a sibling unit test alongside the existing "feature-gates-custom-no-upgrade-with-feature-set-empty" case that exercises the SpecialHandlingSupportExceptionRequired rule when ApiServer.FeatureGates.FeatureSet is empty: create a case named like "feature-gates-special-handling-support-exception-required-with-feature-set-empty", build the config via mkDefaultConfig(), set c.ApiServer.FeatureGates.FeatureSet = "", populate c.ApiServer.FeatureGates.SpecialHandlingSupportExceptionRequired.Enabled = []string{"feature1"} and Disabled = []string{"feature2"} (or similar values), and set expectErr: true so the test asserts the same error behavior as the CustomNoUpgrade case; place it in the same table of test cases in pkg/config/config_test.go.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/config/config_test.go`:
- Around line 822-831: Add a sibling unit test alongside the existing
"feature-gates-custom-no-upgrade-with-feature-set-empty" case that exercises the
SpecialHandlingSupportExceptionRequired rule when
ApiServer.FeatureGates.FeatureSet is empty: create a case named like
"feature-gates-special-handling-support-exception-required-with-feature-set-empty",
build the config via mkDefaultConfig(), set c.ApiServer.FeatureGates.FeatureSet
= "", populate
c.ApiServer.FeatureGates.SpecialHandlingSupportExceptionRequired.Enabled =
[]string{"feature1"} and Disabled = []string{"feature2"} (or similar values),
and set expectErr: true so the test asserts the same error behavior as the
CustomNoUpgrade case; place it in the same table of test cases in
pkg/config/config_test.go.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: 6d4cfacb-7083-4be3-94e2-c11618fec24b
⛔ Files ignored due to path filters (1)
etcd/vendor/github.com/openshift/microshift/pkg/config/apiserver.gois excluded by!**/vendor/**
📒 Files selected for processing (2)
pkg/config/apiserver.gopkg/config/config_test.go
…FeatureSet Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> pre-commit.check-secrets: ENABLED
|
@agullon: This pull request references Jira Issue OCPBUGS-78594, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@agullon: This pull request references Jira Issue OCPBUGS-78594, which is invalid:
Comment DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@agullon: This pull request references Jira Issue OCPBUGS-78594, which is invalid:
Comment DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@agullon: This pull request references Jira Issue OCPBUGS-78594, which is invalid:
Comment DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/jira refresh |
|
@agullon: This pull request references Jira Issue OCPBUGS-78594, which is valid. 3 validation(s) were run on this bug
DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/retest |
|
/cherry-pick release-4.21 |
|
@agullon: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
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. |
|
@agullon: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
|
/verified by @copejon,ci |
|
@copejon: This PR has been marked as verified by DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
/lgtm |
|
@agullon: This pull request references Jira Issue OCPBUGS-78594, which is valid. 3 validation(s) were run on this bug
DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: agullon, copejon The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@agullon: Jira Issue OCPBUGS-78594: All pull requests linked via external trackers have merged: All linked pull requests have the DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
@agullon: #6367 failed to apply on top of branch "release-4.21": DetailsIn response to this:
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. |
Summary
featureSetis empty butcustomNoUpgradeorspecialHandlingSupportExceptionRequiredenabled/disabled lists are populated,ToApiserverArgs()applies the feature gates to kube-apiserver without creating an upgrade lock file. This means custom feature gates get applied without upgrade protection.validateFeatureGates()that rejects non-emptycustomNoUpgradeandspecialHandlingSupportExceptionRequiredlists whenFeatureSetis empty, preventing users from accidentally running unprotected custom feature gates.apiserver.go.