fix(chart): Protect resource rendering when resources value is null #630
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.
Description
This PR fixes a Helm templating issue where
resources:field would render with no content when the resources value is null or undefined invalues.yaml, resulting in invalid YAML output.Changes Made
Added
withblock protection indeployments/kai-scheduler/templates/services/operator.yaml:resources:field with{{- with .Values.operator.resources }}blockresources:section is omitted when the value is null/undefinedVerified existing protections in
deployments/kai-scheduler/templates/kai-config.yaml:{{- if .Values.<component>.resources }}checksProblem
Without the
withblock, whenresourcesis not defined invalues.yaml, the template would render:resources:This produces invalid YAML with an empty mapping, which can cause deployment failures.
Solution
With the
withblock, whenresourcesis not defined, the entireresources:field is omitted:Benefits
resources:fields in rendered manifestsRelated Issues
N/A
Checklist
Breaking Changes
None. This is a bug fix that prevents invalid YAML generation. Existing deployments that define resources will continue to work unchanged.
Additional Notes
Current State in values.yaml
Currently, none of the following components have
resourcesdefined invalues.yaml:This means without this fix, the operator deployment would render with an empty
resources:field.Testing
The fix can be validated using
helm template:Without resources defined (current state):
With resources defined:
helm template kai-scheduler deployments/kai-scheduler \ --set operator.resources.limits.cpu=1000m \ --set operator.resources.limits.memory=512Mi # Result: resources field renders correctly with defined limits