Skip to content

Conversation

towca
Copy link
Collaborator

@towca towca commented Jun 10, 2025

What type of PR is this?

/kind bug

What this PR does / why we need it:

The --drain-priority-config flag was only parsed if isFlagPassed() returned true for it. However, isFlagPassed() would actually silently never work. The implementation relied on walking the flags parsed by the standard Go "flag" pkg. This seems like it would work since CA defines its flags using the standard "flag" pkg. However, the flags are then actually parsed and processed by the "github.com/spf13/pflag" pkg, so isFlagPassed() could never see them.

This commit removes isFlagPassed() and replaces the calls with a pkg-provided pflag.CommandLine.Changed(). Unit tests are added to verify that the flag is correctly parsed after this change.

Which issue(s) this PR fixes:

Fixes #7851

Does this PR introduce a user-facing change?

The --drain-priority-config flag is now correctly parsed and taken into account.

The --drain-priority-config flag was only parsed if isFlagPassed()
returned true for it. However, isFlagPassed() would actually silently
never work. The implementation relied on walking the flags parsed by
the standard Go "flag" pkg. This seems like it would work since CA
defines its flags using the standard "flag" pkg. However, the flags
are then actually parsed and processed by the "github.com/spf13/pflag"
pkg, so isFlagPassed() could never see them.

This commit replaces removes isFlagPassed() and replaces the calls
with a pkg-provided pflag.CommandLine.Changed(). Unit tests are added
to verify that the flag is correctly parsed after this change.
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 10, 2025
@k8s-ci-robot k8s-ci-robot requested review from feiskyer and x13n June 10, 2025 15:04
@k8s-ci-robot k8s-ci-robot added area/cluster-autoscaler approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 10, 2025
@jackfrancis
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 10, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jackfrancis, towca

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

@jackfrancis jackfrancis merged commit 67da65c into kubernetes:master Jun 10, 2025
5 of 9 checks passed
@jackfrancis
Copy link
Contributor

/cherry-pick cluster-autoscaler-release-1.30
/cherry-pick cluster-autoscaler-release-1.31
/cherry-pick cluster-autoscaler-release-1.32
/cherry-pick cluster-autoscaler-release-1.33

@k8s-infra-cherrypick-robot

@jackfrancis: #8219 failed to apply on top of branch "cluster-autoscaler-release-1.30":

Applying: Fix parsing --drain-priority-config
Using index info to reconstruct a base tree...
A	cluster-autoscaler/config/flags/flags.go
A	cluster-autoscaler/config/flags/flags_test.go
Falling back to patching base and 3-way merge...
Auto-merging cluster-autoscaler/main_test.go
CONFLICT (content): Merge conflict in cluster-autoscaler/main_test.go
Auto-merging cluster-autoscaler/main.go
CONFLICT (content): Merge conflict in cluster-autoscaler/main.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Fix parsing --drain-priority-config

In response to this:

/cherry-pick cluster-autoscaler-release-1.30
/cherry-pick cluster-autoscaler-release-1.31
/cherry-pick cluster-autoscaler-release-1.32
/cherry-pick cluster-autoscaler-release-1.33

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.

@jackfrancis
Copy link
Contributor

/cherry-pick cluster-autoscaler-release-1.31

@jackfrancis
Copy link
Contributor

/cherry-pick cluster-autoscaler-release-1.32

@jackfrancis
Copy link
Contributor

/cherry-pick cluster-autoscaler-release-1.33

@k8s-infra-cherrypick-robot

@jackfrancis: #8219 failed to apply on top of branch "cluster-autoscaler-release-1.31":

Applying: Fix parsing --drain-priority-config
Using index info to reconstruct a base tree...
A	cluster-autoscaler/config/flags/flags.go
A	cluster-autoscaler/config/flags/flags_test.go
Falling back to patching base and 3-way merge...
Auto-merging cluster-autoscaler/main_test.go
CONFLICT (content): Merge conflict in cluster-autoscaler/main_test.go
Auto-merging cluster-autoscaler/main.go
CONFLICT (content): Merge conflict in cluster-autoscaler/main.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Fix parsing --drain-priority-config

In response to this:

/cherry-pick cluster-autoscaler-release-1.31

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-infra-cherrypick-robot

@jackfrancis: #8219 failed to apply on top of branch "cluster-autoscaler-release-1.32":

Applying: Fix parsing --drain-priority-config
Using index info to reconstruct a base tree...
A	cluster-autoscaler/config/flags/flags.go
A	cluster-autoscaler/config/flags/flags_test.go
Falling back to patching base and 3-way merge...
Auto-merging cluster-autoscaler/main_test.go
CONFLICT (content): Merge conflict in cluster-autoscaler/main_test.go
Auto-merging cluster-autoscaler/main.go
CONFLICT (content): Merge conflict in cluster-autoscaler/main.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Patch failed at 0001 Fix parsing --drain-priority-config

In response to this:

/cherry-pick cluster-autoscaler-release-1.32

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-infra-cherrypick-robot

@jackfrancis: new pull request could not be created: failed to create pull request against kubernetes/autoscaler#cluster-autoscaler-release-1.33 from head k8s-infra-cherrypick-robot:cherry-pick-8219-to-cluster-autoscaler-release-1.33: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"No commits between kubernetes:cluster-autoscaler-release-1.33 and k8s-infra-cherrypick-robot:cherry-pick-8219-to-cluster-autoscaler-release-1.33"}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request","status":"422"}

In response to this:

/cherry-pick cluster-autoscaler-release-1.33

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.

@towca
Copy link
Collaborator Author

towca commented Jul 28, 2025

@jackfrancis The cherry-picks don't apply cleanly because the logic was moved from main.go to config/flags.go. But it seems that the bug is there all the way down to 1.30 :/

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/cluster-autoscaler cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

drain-priority-config doesn't work
4 participants