fix(slime): render spec.replicas correctly when Values.replicas is 0#335
Merged
Conversation
Go template truthiness treats numeric 0 as falsy, so the previous `.Values.replicas` check skipped the `replicas:` block when replicas was explicitly set to 0. Kubernetes then defaulted the Deployment to 1 replica. Switch to `(ne .Values.replicas nil)` to distinguish "unset" from "explicitly 0", matching the existing pattern in the php chart. Bump chart version 1.3.1 -> 1.3.2 (patch / bugfix). Refs: SREP-4455
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a bug in the
slimechart whereValues.replicas: 0is silently ignored and the Deployment is rendered withoutspec.replicas, causing Kubernetes to default the replica count to 1.Root cause
Go template truthiness treats the numeric value
0as falsy. The condition attemplates/deployment.yaml:18used.Values.replicasdirectly, so whenreplicas: 0was set theandshort-circuited to false and the entirereplicas:block was skipped during rendering.The same pattern is already used in
php/templates/deployment.yaml:16(ne .Values.replicaCount nil); this PR aligns slime with that precedent.Changes
slime/templates/deployment.yaml: switch the replicas guard to a nil comparison.slime/Chart.yaml: bumpversionfrom1.3.1to1.3.2(semver patch / bugfix).Behavior matrix
replicasunsetspec.replicasspec.replicas(unchanged)replicas: 2spec.replicas: 2spec.replicas: 2(unchanged)replicas: 0spec.replicas→ K8s defaults to 1spec.replicas: 0autoscaling.enabled: true+replicas: 2spec.replicas(HPA wins)spec.replicas(unchanged)autoscaling.enabled: true+replicas: 0spec.replicas(HPA wins)spec.replicas(unchanged)Verification
Test values used for
helm templateruns:1. Before the fix — bug reproduced (no
spec.replicas)2. After the fix —
replicas: 0is rendered correctly3. After the fix —
autoscaling.enabled: true+replicas: 0still omitsspec.replicas(HPA wins)4.
helm lint --strictpasses on all examplesRan
helm lint --strict -f examples/<name>.yaml slime/againstdeployment,deployment-hpa,deployment-ingress,cronjob, andcronjob-advanced. All five passed:Note:
kubevalwas not installed locally, so thekubevalportion ofmake lintis delegated to CI.Test plan
helm templaterendersspec.replicas: 0whenreplicas: 0is sethelm templateomitsspec.replicaswhenautoscaling.enabled: true+replicas: 0helm lint --strictpasses for all five example values filesmake lint(kubeval included) successfully