-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
Nil pointer dereference in KCM after v1 HPA patch request #107038
Comments
/sig autoscaling |
/triage accepted |
I would like to work on this. |
Guidance needed. Could you elaborate more about that what is the cause of this bug ? |
/assign |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The issue has been marked as an important bug and triaged. Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle frozen |
/remove-lifecycle rotten |
This issue is labeled with You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
/help |
@pacoxu: GuidelinesPlease ensure that the issue body includes answers to the following questions:
For more details on the requirements of such an issue, please see here and ensure that they are met. If this request no longer meets these requirements, the label can be removed In 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/test-infra repository. |
/remove-lifecycle rotten |
This issue is labeled with You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
@pacoxu, I know this is old, but:
Fixing this now and getting it back to pre-1.27 is more than 3 versions (and 1.26 is EOL next month), so I assume it would be pointless to try and fix the v1 API now by finishing #107126? -- since we couldn't backport it to a version that mattered anyway? (As for why I'm interested, I have a downstream customer running < 1.27 that wanted it fixed and I was trying to see what I could do to accommodate that) |
Do you mean this is fixed and this issue can be closed for 1.27+?
Only v1.26 can be fixed in community.
I'm afraid that you have to maintain a specific version or use some webhook(or kyverno like https://kyverno.io/policies/other/add-default-resources/add-default-resources/) to make it not happen.
|
Correct, this is fixed and the issue can be closed for 1.27+. I happened across that accidentally while testing a fix -- it was kind of a "wait, why can't I break this anymore" moment, and then I traced it back to when it changed -- but I did test it.
Thanks for confirming, I appreciate it.
Thanks for your time and the suggestions -- I'm confident that would work ( I do a lot of work downstream on OpenShift, and we do have our own fork, I just try to avoid having too many "carry patches" if I can help it). Thanks! |
What happened?
If we create a v2beta2 HPA object with fields specified for the scaleUp or scaleDown behavior, these values can be modified through the v1 version of the same object by changing the annotation for autoscaling.alpha.kubernetes.io/behavior. If we patch the scaleUp or scaleDown field in the annotation to null, the patch request will get accepted without the default values for scaleUp or scaleDown being applied. This will result in a panic in KCM when it tries to deference a nil pointer:
This is panic is occurring here: https://github.com/kubernetes/kubernetes/blob/v1.21.2/pkg/controller/podautoscaler/horizontal.go#L885
What did you expect to happen?
The patch request to the v1 HPA object should have applied the default value for the scaleUp or scaleDown fields when the annotation edit set it to null. When the v2beta2 object is updated, omitting the scaleUp or scaleDown properties will result in default values being applied so it is assumed that no fields in this struct are nil:
kubernetes/pkg/apis/autoscaling/v2/defaults.go
Line 104 in 6ac2d8e
How can we reproduce it (as minimally and precisely as possible)?
Using v1.21.2:
Change this annotation:
To this:
Checking KCM logs:
Anything else we need to know?
No response
Kubernetes version
Cloud provider
OS version
Install tools
Container runtime (CRI) and and version (if applicable)
Related plugins (CNI, CSI, ...) and versions (if applicable)
The text was updated successfully, but these errors were encountered: