Skip to content

Conversation

@win5923
Copy link
Collaborator

@win5923 win5923 commented Dec 14, 2025

Why are these changes needed?

Check #4268 (comment)

Some helm values, e.g. leaderElectionEnabled and EnableMetrics, are passed as flags, see here:

{{- if hasKey .Values "leaderElectionEnabled" -}}
{{- $argList = append $argList (printf "--enable-leader-election=%t" .Values.leaderElectionEnabled) -}}
{{- end -}}
{{- if and (hasKey .Values "metrics") (hasKey .Values.metrics "enabled") }}
{{- $argList = append $argList (printf "--enable-metrics=%t" .Values.metrics.enabled) -}}

Then these flags get ignored when configuration.enabled=true, see here:

if configFile != "" {
var err error
configData, err := os.ReadFile(configFile)
exitOnError(err, "failed to read config file")
config, err = decodeConfig(configData, scheme)
exitOnError(err, "failed to decode config file")
} else {
config.MetricsAddr = metricsAddr
config.ProbeAddr = probeAddr
config.EnableLeaderElection = &enableLeaderElection
config.LeaderElectionNamespace = leaderElectionNamespace
config.ReconcileConcurrency = reconcileConcurrency
config.WatchNamespace = watchNamespace
config.LogFile = logFile
config.LogFileEncoder = logFileEncoder
config.LogStdoutEncoder = logStdoutEncoder
config.EnableBatchScheduler = enableBatchScheduler
config.BatchScheduler = batchScheduler
config.UseKubernetesProxy = useKubernetesProxy
config.DeleteRayJobAfterJobFinishes = os.Getenv(utils.DELETE_RAYJOB_CR_AFTER_JOB_FINISHES) == "true"
config.EnableMetrics = enableMetrics
config.QPS = &qps
config.Burst = &burst
}

# Configuration for the KubeRay operator.
configuration:
# -- Whether to enable the configuration feature. If enabled, a ConfigMap will be created and mounted to the operator.
enabled: false

args:
{{- $argList := list -}}
{{- if .Values.configuration.enabled -}}
{{- $argList = append $argList "--config" -}}
{{- $argList = append $argList "/etc/kuberay/config.yaml" -}}
{{- end -}}

{{- if .Values.configuration.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "kuberay-operator.deployment.name" . }}-config
namespace: {{ .Release.Namespace }}
labels:
{{- include "kuberay-operator.labels" . | nindent 4 }}
{{- with .Values.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
data:
config.yaml: |
apiVersion: config.ray.io/v1alpha1
kind: Configuration
{{- if .Values.configuration.defaultContainerEnvs }}
defaultContainerEnvs:
{{- toYaml .Values.configuration.defaultContainerEnvs | nindent 4 }}
{{- end }}
{{- end }}

This PR includes all flag-based configuration options in the ConfigMap template, ensuring they are properly read from helm values and injected into the ConfigMap.

  • When configuration.enabled = true, the KubeRay Operator would read all flag-based envs from the ConfigMap, and these values would take precedence over the flag-based configuration.

  • When configuration.enabled = false and the relevant flag-based options are explicitly set in values.yaml (e.g. metrics.enabled = true), the operator would preserving the current flag-based behavior.

Related issue number

Closes #4268

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

@win5923 win5923 marked this pull request as ready for review December 14, 2025 13:38
@win5923 win5923 marked this pull request as draft December 14, 2025 13:51
@win5923 win5923 marked this pull request as ready for review December 14, 2025 14:38
Comment on lines +2 to +21
{{- if hasKey .Values "reconcileConcurrency" }}
{{- $rc := toString .Values.reconcileConcurrency }}
{{- if not (regexMatch "^[1-9][0-9]*$" $rc) }}
{{- fail (printf "values.reconcileConcurrency must be a positive integer, got %q" $rc) }}
{{- end }}
{{- end }}
{{- if hasKey .Values "kubeClient" }}
{{- if hasKey .Values.kubeClient "qps" }}
{{- $qps := toString .Values.kubeClient.qps }}
{{- if not (regexMatch "^[+-]?[0-9]+(\\.[0-9]+)?$" $qps) }}
{{- fail (printf "values.kubeClient.qps must be a valid float number, got %q" $qps) }}
{{- end }}
{{- end }}
{{- if hasKey .Values.kubeClient "burst" }}
{{- $burst := toString .Values.kubeClient.burst }}
{{- if not (regexMatch "^[0-9]+$" $burst) }}
{{- fail (printf "values.kubeClient.burst must be a non-negative integer, got %q" $burst) }}
{{- end }}
{{- end }}
{{- end }}
Copy link
Collaborator Author

@win5923 win5923 Dec 14, 2025

Choose a reason for hiding this comment

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

Copy from

{{- if hasKey .Values "reconcileConcurrency" -}}
{{- $rc := toString .Values.reconcileConcurrency }}
{{- if not (regexMatch "^[1-9][0-9]*$" $rc) }}
{{- fail (printf "values.reconcileConcurrency must be a positive integer, got %q" $rc) }}
{{- end }}
{{- $argList = append $argList (printf "--reconcile-concurrency=%v" .Values.reconcileConcurrency) -}}
{{- end -}}
{{- if hasKey .Values "kubeClient" -}}
{{- if hasKey .Values.kubeClient "qps" -}}
{{- $qps := toString .Values.kubeClient.qps }}
{{- if not (regexMatch "^[+-]?[0-9]+(\\.[0-9]+)?$" $qps) }}
{{- fail (printf "values.kubeClient.qps must be a valid float number, got %q" $qps) }}
{{- end }}
{{- $argList = append $argList (printf "--qps=%v" .Values.kubeClient.qps) -}}
{{- end -}}
{{- if hasKey .Values.kubeClient "burst" -}}
{{- $burst := toString .Values.kubeClient.burst }}
{{- if not (regexMatch "^[0-9]+$" $burst) }}
{{- fail (printf "values.kubeClient.burst must be a non-negative integer, got %q" $burst) }}
{{- end }}

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.

[Bug] Some ray-operator helm values aren't applied when ConfigMap is enabled

1 participant