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
Copy link
Contributor

@seanlaii seanlaii left a comment

Choose a reason for hiding this comment

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

Thanks! Overall this looks great to me.
Aside from the comment below, I have one minor suggestion: should we consider avoiding setting this flag?

@win5923
Copy link
Collaborator Author

win5923 commented Dec 19, 2025

I have one minor suggestion: should we consider avoiding setting this flag?

I think both are fine, This flag is primarily designed for complex structures that cannot be easily passed via command-line flags (like defaultContainerEnvs, headSidecarContainers).

Signed-off-by: win5923 <[email protected]>
@seanlaii
Copy link
Contributor

seanlaii commented Dec 19, 2025

I think both are fine, This flag is primarily designed for complex structures that cannot be easily passed via command-line flags (like defaultContainerEnvs, headSidecarContainers).

Sorry for the confusion. What I mean is should we consider avoiding setting the command line flags when they enable the config map mode?
IIUC, the command line flags will still be set when enabling the config map mode.
Maybe the users will be confused when they still see the command line flags while using the config map mode.

@win5923
Copy link
Collaborator Author

win5923 commented Dec 19, 2025

Sorry for the confusion. What I mean is should we consider avoiding setting the command line flags when they enable the config map mode?
IIUC, the command line flags will still be set when enabling the config map mode.
Maybe the users will be confused when they still see the command line flags while using the config map mode.

Oh, Thanks for catching this. I think we should consider avoiding setting the command line flags when they enable the config map mode.

{{- end -}}
{{- end -}}
{{- end -}}
{{- $argList = append $argList (include "kuberay.featureGates" . | trim) -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! To confirm, featureGates is not supported in config map, is it correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

@seanlaii seanlaii left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM!

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

2 participants