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
Add nil checks for hpa object target type values #121015
Add nil checks for hpa object target type values #121015
Conversation
This issue is currently awaiting triage. If a SIG or subproject determines this is a relevant issue, they will accept it by applying the The 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. |
Hi @Lukasz-AWS. 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 Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
/lgtm |
LGTM label has been added. Git tree hash: 308ca288672b5a830a7059e8d77174e05e35ff14
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: liggitt, Lukasz-AWS 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 |
/retest |
1 similar comment
/retest |
Not cherry picking to 1.26, as 1.26 will forcibly change the type.
it becomes with no crashes
|
wait, what? is that true when creating a brand new object? |
yes appears so, this is how I tested against the other versions which led to no changes and kcm crashing:
|
oh.... I bet that's because of v1 conversion logic, which infers the type from which *value field is non-nil (because there's no dedicated type field in v1): kubernetes/pkg/apis/autoscaling/v1/conversion.go Lines 49 to 54 in 755644a
kubernetes/pkg/apis/autoscaling/v1/conversion.go Lines 85 to 89 in 755644a
kubernetes/pkg/apis/autoscaling/v1/conversion.go Lines 217 to 222 in 755644a
prior to #114358 which was included in 1.27, HPA objects were persisted in etcd in v1 format, so every HPA object would interact with the v1 conversion |
go ahead and backport the change to 1.26 so the 1.26 controller is resilient to data it could encounter speaking to a 1.27 server |
…121015-upstream-release-1.27 Automated cherry pick of #121015: Add nil checks for hpa object target type values
…121015-upstream-release-1.28 Automated cherry pick of #121015: Add nil checks for hpa object target type values
…121015-upstream-release-1.26 Automated cherry pick of #121015: Add nil checks for hpa object target type values
What type of PR is this?
/kind bug
What this PR does / why we need it:
Fixes a bug where if the corresponding value (value, averageValue) of the the type of target (Value, AverageValue) is not set but the opposite type is, HPA object would pass validation but then cause kube-controller-manager to crash loop due to nil pointer dereference looking for that corresponding value. This PR adds a nil check to make sure kube-controller-manager doesn't crash. The change to fix the validation is being worked on here #120373
Which issue(s) this PR fixes:
N/A
Fixes #
Special notes for your reviewer:
Observed in 1.27 and 1.28, possibly might be an issue in earlier versions as well.
Can be replicated by deploying an hpa with a valid scaleTargetRef and adding this object to the metrics. On sync kcm will crash due to nil pointer dereference.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: