Skip to content

Conversation

@lokielse
Copy link
Contributor

@lokielse lokielse commented Nov 11, 2025

Description

image

This PR fixes a Helm templating issue where resources: field would render with no content when the resources value is null or undefined in values.yaml, resulting in invalid YAML output.

Changes Made

  1. Added with block protection in deployments/kai-scheduler/templates/services/operator.yaml:

    • Wrapped the resources: field with {{- with .Values.operator.resources }} block
    • Ensures the entire resources: section is omitted when the value is null/undefined
    • Changed from unconditional rendering to conditional rendering
  2. Verified existing protections in deployments/kai-scheduler/templates/kai-config.yaml:

    • Confirmed all 6 components already have proper {{- if .Values.<component>.resources }} checks
    • Components: binder, podgroupcontroller, queuecontroller, admission, nodescaleadjuster, scheduler

Problem

Without the with block, when resources is not defined in values.yaml, the template would render:

resources:

This produces invalid YAML with an empty mapping, which can cause deployment failures.

Solution

With the with block, when resources is not defined, the entire resources: field is omitted:

{{- with .Values.operator.resources }}
resources:
  {{- toYaml . | nindent 12 }}
{{- end }}

Benefits

  • Prevents invalid YAML: No empty resources: fields in rendered manifests
  • Flexible configuration: Resources can be optionally defined in values.yaml
  • Consistent pattern: Aligns with the pattern already used in kai-config.yaml
  • Backward compatible: Existing configurations with resources defined continue to work

Related Issues

N/A

Checklist

  • Self-reviewed
  • Added/updated tests (if needed)
  • Updated CHANGELOG.md (if needed)
  • Updated documentation (if needed)

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 resources defined in values.yaml:

  • operator
  • binder
  • podgroupcontroller
  • queuecontroller
  • admission
  • nodescaleadjuster
  • scheduler

This means without this fix, the operator deployment would render with an empty resources: field.

Testing

The fix can be validated using helm template:

  1. Without resources defined (current state):

    helm template kai-scheduler deployments/kai-scheduler
    # Before fix: renders "resources:" with no content
    # After fix: "resources:" field is completely omitted
  2. 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

Copy link
Collaborator

@enoodle enoodle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@enoodle enoodle merged commit 0f2ef2d into NVIDIA:main Nov 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants