Fix cluster-autoscaler VPA template with empty containerPolicy#9387
Fix cluster-autoscaler VPA template with empty containerPolicy#9387snigdhasambitak wants to merge 2 commits intokubernetes:masterfrom
Conversation
|
Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: snigdhasambitak The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @snigdhasambitak! |
|
Hi @snigdhasambitak. 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 Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
When `vpa.containerPolicy` is set to `{}` (the default), the template
renders invalid YAML:
```yaml
- containerName: aws-cluster-autoscaler
{}
```
A flow mapping `{}` after a block mapping key on the previous line is
a YAML syntax error, causing `helm template` to fail with:
"error converting YAML to JSON: yaml: line 22: did not find expected key"
Fix by wrapping the containerPolicy rendering in a `with` block so
that an empty map produces no output instead of `{}`.
360f19c to
d6dfb0f
Compare
What type of PR is this?
/kind bug
What this PR does / why we need it
Fixes the cluster-autoscaler Helm chart VPA template (
templates/vpa.yaml) which renders invalid YAML whenvpa.containerPolicyis set to{}(the default value).Which issue(s) this PR fixes
None found -- filing via this PR.
Bug
When
vpa.enabled: truewith the defaultcontainerPolicy: {}, the template on line 21:Renders as:
A flow mapping
{}after an already-started block mapping key is a YAML syntax error, causinghelm templateto fail:Fix
Wrap the
containerPolicyrendering in awithblock so an empty map produces no output instead of{}:How to reproduce
helm template test cluster-autoscaler \ --repo https://kubernetes.github.io/autoscaler \ --version 9.56.0 \ --set vpa.enabled=true \ --set vpa.updateMode=OffVerification
After the fix, both cases render valid YAML:
containerPolicy: {}-- renderscontainerNameonly (no extra output)containerPolicy: {controlledResources: [cpu, memory]}-- renders correctly with resources listed