← Back to Pull requests

[Feature] Add IPv6 support #5215

Open
400Ping opened this pull request with 881 lines diff across 19 files
View on GitHub
400Ping 400Ping commented on Aug 30, 2026 11:26 UTC
Author

Why are these changes needed?

This PR adds IPv6-only support to KubeRay.

In an IPv6-only Kubernetes cluster, KubeRay hard-coded --dashboard-host=0.0.0.0, so the
Ray dashboard only bound IPv4 and RayService/RayJob could not reach it. Several places also
formatted host:port with fmt.Sprintf, which produces invalid URLs for IPv6 addresses, and
the auto-generated mTLS certificates only covered the IPv4 loopback.

This change:

  • Derives the dashboard-host default from the head Service's IP family: the controller

  • reads spec.ipFamilies (falling back to the family of clusterIP, then IPv4) and writes
    :: or 0.0.0.0 into the generated ray start command. No shell logic runs inside the
    Pod, and KUBERAY_GEN_RAY_START_CMD stays a plain command. Users can still override
    dashboard-host in rayStartParams.
  • Uses localhost instead of 127.0.0.1 for in-Pod addresses (RAY_ADDRESS on the head,

  • sidecar ray job submit) so they resolve in either family, and uses net.JoinHostPort
    when building URLs from Pod IPs.
  • mTLS: adds the loopback SAN matching the Pod's IP family (::1 for IPv6, 127.0.0.1 for

  • IPv4) and switches the wait-for-tls-ip-san init container from a textual grep to
    openssl verify -verify_ip, so IPv6 SANs match regardless of case or zero compression.
    The openssl error is printed on each retry.
  • Adds an IPv6-only Buildkite E2E job (kind ipFamily: ipv6, Ray 2.58.0) covering

  • TestRayClusterIPv6, TestRayClusterTLSIPv6, and TestRayServiceIPv6. The job strips
    the Buildkite host's DNS search domain from the kind node, because with ndots:5 it
    leaks into Pods and makes CoreDNS return SERVFAIL for the head Service name in an
    IPv6-only cluster. On failure the job also collects init container logs, events, and
    kind export logs.
  • Updates docs/guidance/rayStartParams.md.
  • Scope and notes:

  • Single-stack IPv6-only only. Dual-stack is left for a follow-up.

  • Ray's node address auto-detection works in IPv6-only Pods, so KubeRay does not set

  • --node-ip-address.
  • Ray 2.56.0 or later is required for IPv6.

  • A RayService on an IPv6-only cluster needs http_options.host: "::" in serveConfigV2.
  • Related issue number

    Related to ray-project/ray#54660.

    Labels

  • If this PR has user-facing changes that require documentation updates at

  • release time, I have added the doc-updates-required label.
  • If this PR contains breaking changes, I have added the breaking-change

  • label.

    Checks

  • I've made sure the tests are passing.

  • Testing Strategy

  • - [x] Unit tests
    - [x] Manual tests
    - [ ] This PR is not tested :(

    Diff: 881 lines (+715 / -166) across 19 files Reviewer: justinyeh1995 Review duration: 133135m
    All Vouch review confidence checks passed
    Residual risk 0.09 = Change Risk (0.84) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.84 · 881 lines diff across 19 files
    0.84
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.92 · 5 substantive comment(s)
    0.92
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    89%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Mass File Touch mass_file_touch
    0.080
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    37 items
    machichima machichima commented on code on Sep 23, 2026 09:58 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -1371,6 +1406,14 @@ func setContainerEnvVars(pod *corev1.Pod, rayNodeType rayv1.RayNodeType, fqdnRay
     
     func setMissingRayStartParams(ctx context.Context, rayStartParams map[string]string, nodeType rayv1.RayNodeType, headPort string, fqdnRayIP string) (completeStartParams map[string]string) {
     	log := ctrl.LoggerFrom(ctx)
    +	// Ray's automatic node address detection can select a loopback, link-local,
    +	// or secondary-interface address that other Pods cannot reach. Kubernetes
    +	// already exposes the canonical primary Pod IP, so advertise it by default
    +	// while preserving an explicit user override for multi-network Pods.
    +	if _, ok := rayStartParams["node-ip-address"]; !ok {
    +		rayStartParams["node-ip-address"] = "$" + KubeRayPodIPEnvVar
    +	}

    I think Ray should be able to resolve it and do not need us to pass the node-ip-address explicitly?

    machichima machichima commented on code on Sep 23, 2026 13:36 UTC
    Code Review
    .buildkite/collect-ipv6-e2e-logs.sh:1

    Could you please explain why we need extra script for collecting IPv6 test logs?

    machichima machichima commented on Sep 24, 2026 01:05 UTC
    Contributor

    cc @yjaw @justinyeh1995 to review together if you are interested

    400Ping 400Ping commented on code on Sep 24, 2026 02:32 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -1371,6 +1406,14 @@ func setContainerEnvVars(pod *corev1.Pod, rayNodeType rayv1.RayNodeType, fqdnRay
     
     func setMissingRayStartParams(ctx context.Context, rayStartParams map[string]string, nodeType rayv1.RayNodeType, headPort string, fqdnRayIP string) (completeStartParams map[string]string) {
     	log := ctrl.LoggerFrom(ctx)
    +	// Ray's automatic node address detection can select a loopback, link-local,
    +	// or secondary-interface address that other Pods cannot reach. Kubernetes
    +	// already exposes the canonical primary Pod IP, so advertise it by default
    +	// while preserving an explicit user override for multi-network Pods.
    +	if _, ok := rayStartParams["node-ip-address"]; !ok {
    +		rayStartParams["node-ip-address"] = "$" + KubeRayPodIPEnvVar
    +	}

    Good catch. I verified on an IPv6-only kind cluster with ray 2.58.0: without --node-ip-address, both head and worker auto-detect their pod IPv6 and cross-node tasks work, so I'll drop the default injection and keep KUBERAY_POD_IP only for selecting the dashboard-host family.

    400Ping 400Ping commented on code on Sep 24, 2026 02:32 UTC
    Code Review
    .buildkite/collect-ipv6-e2e-logs.sh:1

    The inline collection only grabs the operator log, but the IPv6 failures were cluster-network level (CoreDNS/kube-proxy), which only kind export logs captures.

    justinyeh1995 justinyeh1995 commented on code on Sep 24, 2026 08:22 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_mtls_controller_test.go:1
    @@ -314,7 +316,7 @@ func TestMTLSController_AutoGenerate_UpdatesIPAddresses(t *testing.T) {
     				utils.RayNodeTypeLabelKey: string(rayv1.HeadNode),
     			},
     		},
    -		Status: corev1.PodStatus{PodIP: "10.244.0.5"},
    +		Status: corev1.PodStatus{PodIP: "2001:db8::5"},

    Can we preserve the existing IPv4 test as well? A table test over IPv4/IPv6 would work.

    justinyeh1995 justinyeh1995 commented on code on Sep 25, 2026 03:52 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -512,13 +524,13 @@ if ! command -v openssl >/dev/null 2>&1; then
     fi
     echo "Waiting for TLS cert to include IP SAN for ${POD_IP}..."
     while true; do
    -  if openssl x509 -in "${CERT}" -noout -text 2>/dev/null | grep -qE "IP Address:${POD_IP}([^0-9.]|$)"; then
    +  if openssl verify -CAfile "${CA_CERT}" -verify_ip "${POD_IP}" "${CERT}" >/dev/null 2>&1; then

    Is the broader validation intentional? If so, could we expose the verification error instead of reporting every failure as a missing IP SAN?

    400Ping 400Ping commented on code on Sep 26, 2026 03:52 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_mtls_controller_test.go:1
    @@ -314,7 +316,7 @@ func TestMTLSController_AutoGenerate_UpdatesIPAddresses(t *testing.T) {
     				utils.RayNodeTypeLabelKey: string(rayv1.HeadNode),
     			},
     		},
    -		Status: corev1.PodStatus{PodIP: "10.244.0.5"},
    +		Status: corev1.PodStatus{PodIP: "2001:db8::5"},

    Done in 98e3484. The test is now a table over IPv4 (10.244.0.5/6) and IPv6 (2001:db8::5/6).

    400Ping 400Ping commented on code on Sep 26, 2026 03:59 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -512,13 +524,13 @@ if ! command -v openssl >/dev/null 2>&1; then
     fi
     echo "Waiting for TLS cert to include IP SAN for ${POD_IP}..."
     while true; do
    -  if openssl x509 -in "${CERT}" -noout -text 2>/dev/null | grep -qE "IP Address:${POD_IP}([^0-9.]|$)"; then
    +  if openssl verify -CAfile "${CA_CERT}" -verify_ip "${POD_IP}" "${CERT}" >/dev/null 2>&1; then

    The intent was semantic IP comparison: openssl x509 -text prints IPv6 SANs uppercase and uncompressed, so the previous grep could never match an IPv6 POD_IP. -verify_ip compares the addresses properly. The chain check against the mounted ca.crt is an extra guard, since a cert that doesn't chain to that CA would fail Ray's mTLS handshake anyway.

    justinyeh1995 justinyeh1995 commented on code on Sep 26, 2026 17:04 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -915,6 +927,9 @@ func BuildPod(ctx context.Context, podTemplateSpec corev1.PodTemplateSpec, rayNo
     	ulimitCmd := fmt.Sprintf("ulimit -n ${%s:-65536}", utils.RAY_START_ULIMIT_OPEN_FILES)
     	// Generate the `ray start` command.
     	rayStartCmd := generateRayStartCommand(ctx, rayNodeType, rayStartParams, pod.Spec.Containers[utils.RayContainerIndex].Resources)
    +	if rayNodeType == rayv1.HeadNode && rayStartParams["dashboard-host"] == "$"+KubeRayDashboardHostEnvVar {
    +		rayStartCmd = dashboardHostSetupCommand + "; " + rayStartCmd
    +	}

    Semantic-wise I'd think this belongs to generateRayStartCommand or at least we should log the final command like L1492 does. My reason is that user would read the log but see an incomplete rayStartCmd if the user set ray.io/overwrite-container-cmd.

    justinyeh1995 justinyeh1995 commented on code on Sep 26, 2026 17:58 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -1303,7 +1328,17 @@ func setContainerEnvVars(pod *corev1.Pod, rayNodeType rayv1.RayNodeType, fqdnRay
     
     	// utils.KUBERAY_GEN_RAY_START_CMD stores the `ray start` command generated by KubeRay.
     	// See https://github.com/ray-project/kuberay/issues/1560 for more details.
    -	generatedRayStartCmdEnv := corev1.EnvVar{Name: utils.KUBERAY_GEN_RAY_START_CMD, Value: rayStartCmd}
    +	//
    +	// The command is commonly invoked as `$KUBERAY_GEN_RAY_START_CMD` by users
    +	// who overwrite the Ray container command. Shell parameter expansion is not
    +	// recursive: variable references and control operators produced by expanding
    +	// KUBERAY_GEN_RAY_START_CMD would otherwise remain literal arguments. Prefix
    +	// the generated value with `eval` so the shell parses the operator-generated
    +	// command once more and resolves runtime values such as KUBERAY_POD_IP.
    +	generatedRayStartCmdEnv := corev1.EnvVar{
    +		Name:  utils.KUBERAY_GEN_RAY_START_CMD,
    +		Value: "eval " + rayStartCmd,

    I'd like to discuss prefixing the value of KUBERAY_GEN_RAY_START_CMD with eval. Since it applies to both IPv4 and IPv6 clusters, it would break several existing usages. For example, exec ${KUBERAY_GEN_RAY_START_CMD} in GoogleCloudPlatform/kubernetes-engine-samples fails with exec: eval: not found, and exec bash -lc "${KUBERAY_GEN_RAY_START_CMD}" in Azure/taugrid/managed-workflow-rayjob-cpu.yaml.tmpl fails with syntax error near unexpected token 'then'.

    export X='eval if true; then echo yes; fi'
    
    #  exec ${KUBERAY_GEN_RAY_START_CMD}
    bash -c 'exec ${X}'
    
    # exec bash -lc "${KUBERAY_GEN_RAY_START_CMD}" 
    bash -c 'exec bash -lc "${X}"'
    

    <img width="504" height="109" alt="Image" src="https://github.com/user-attachments/assets/362ea811-e6c1-4500-9f76-9ee6112172c1" />

    Since eval is now only needed for the dashboard-host binding snippet, is there an alternative way to determine the IP family? Could the operator write :: / 0.0.0.0 directly from the head Service's spec.ipFamilies so the env var stays a plain command?

    justinyeh1995 justinyeh1995 commented on code on Sep 27, 2026 06:40 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -512,13 +524,13 @@ if ! command -v openssl >/dev/null 2>&1; then
     fi
     echo "Waiting for TLS cert to include IP SAN for ${POD_IP}..."
     while true; do
    -  if openssl x509 -in "${CERT}" -noout -text 2>/dev/null | grep -qE "IP Address:${POD_IP}([^0-9.]|$)"; then
    +  if openssl verify -CAfile "${CA_CERT}" -verify_ip "${POD_IP}" "${CERT}" >/dev/null 2>&1; then

    Thanks for the explanation and the fix.

    400Ping 400Ping commented on code on Oct 09, 2026 02:44 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -1303,7 +1328,17 @@ func setContainerEnvVars(pod *corev1.Pod, rayNodeType rayv1.RayNodeType, fqdnRay
     
     	// utils.KUBERAY_GEN_RAY_START_CMD stores the `ray start` command generated by KubeRay.
     	// See https://github.com/ray-project/kuberay/issues/1560 for more details.
    -	generatedRayStartCmdEnv := corev1.EnvVar{Name: utils.KUBERAY_GEN_RAY_START_CMD, Value: rayStartCmd}
    +	//
    +	// The command is commonly invoked as `$KUBERAY_GEN_RAY_START_CMD` by users
    +	// who overwrite the Ray container command. Shell parameter expansion is not
    +	// recursive: variable references and control operators produced by expanding
    +	// KUBERAY_GEN_RAY_START_CMD would otherwise remain literal arguments. Prefix
    +	// the generated value with `eval` so the shell parses the operator-generated
    +	// command once more and resolves runtime values such as KUBERAY_POD_IP.
    +	generatedRayStartCmdEnv := corev1.EnvVar{
    +		Name:  utils.KUBERAY_GEN_RAY_START_CMD,
    +		Value: "eval " + rayStartCmd,

    Agreed, and thanks for the examples. In fd81d10 the controller now reads the head Service's spec.ipFamilies and writes :: or 0.0.0.0 into dashboard-host directly.

    justinyeh1995 justinyeh1995 commented on code on Oct 10, 2026 07:25 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller_unit_test.go:1
    @@ -90,6 +90,13 @@ const (
     	MultiKueueController = "kueue.x-k8s.io/multikueue"
     )
     
    +func newTestHeadService(t *testing.T) *corev1.Service {

    I think we do not need this helper function. We can reuse testServices from setupTest(t). setupTest already builds the head Service into testServices.

    justinyeh1995 justinyeh1995 commented on code on Oct 10, 2026 07:27 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller_unit_test.go:1
    @@ -2232,7 +2239,7 @@ func Test_TerminatedHead_RestartPolicy(t *testing.T) {
     	_ = corev1.AddToScheme(newScheme)
     
     	// Only one head Pod and no worker Pods in the RayCluster.
    -	runtimeObjects := testPods[0:1]
    +	runtimeObjects := append([]runtime.Object{newTestHeadService(t)}, testPods[0:1]...)

    	runtimeObjects := append(testServices, testPods[0:1]...)
    

    justinyeh1995 justinyeh1995 commented on code on Oct 10, 2026 07:35 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller_unit_test.go:1
    @@ -2320,7 +2327,7 @@ func Test_RunningPods_RayContainerTerminated(t *testing.T) {
     	_ = corev1.AddToScheme(newScheme)
     
     	// Only one head Pod and no worker Pods in the RayCluster.
    -	runtimeObjects := testPods[0:1]
    +	runtimeObjects := append([]runtime.Object{newTestHeadService(t)}, testPods[0:1]...)

    ditto

    justinyeh1995 justinyeh1995 commented on code on Oct 10, 2026 07:35 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller_unit_test.go:1
    @@ -3422,7 +3429,7 @@ func TestEvents_FailedPodCreation(t *testing.T) {
     				Create: func(_ context.Context, _ client.WithWatch, _ client.Object, _ ...client.CreateOption) error {
     					return test.errInject
     				},
    -			}).WithRuntimeObjects(testPods...).Build()
    +			}).WithRuntimeObjects(append([]runtime.Object{newTestHeadService(t)}, testPods...)...).Build()

    ditto

    justinyeh1995 justinyeh1995 commented on code on Oct 10, 2026 07:35 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller_unit_test.go:1
    @@ -3726,7 +3733,7 @@ func TestReconcile_PodsWithAuthToken(t *testing.T) {
     
     	testRayCluster.Spec.AuthOptions = &rayv1.AuthOptions{Mode: rayv1.AuthModeToken}
     
    -	fakeClient := clientFake.NewClientBuilder().WithRuntimeObjects().Build()
    +	fakeClient := clientFake.NewClientBuilder().WithRuntimeObjects(newTestHeadService(t)).Build()

    ditto

    justinyeh1995 justinyeh1995 commented on code on Oct 10, 2026 07:35 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller_unit_test.go:1
    @@ -3950,7 +3957,7 @@ func TestReconcilePodsWithAuthTokenSecretName(t *testing.T) {
     		SecretName: &providedSecretName,
     	}
     
    -	fakeClient := clientFake.NewClientBuilder().Build()
    +	fakeClient := clientFake.NewClientBuilder().WithRuntimeObjects(newTestHeadService(t)).Build()

    ditto

    400Ping 400Ping commented on code on Oct 13, 2026 15:26 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller_unit_test.go:1
    @@ -90,6 +90,13 @@ const (
     	MultiKueueController = "kueue.x-k8s.io/multikueue"
     )
     
    +func newTestHeadService(t *testing.T) *corev1.Service {

    Done

    justinyeh1995 justinyeh1995 commented on code on Oct 14, 2026 13:09 UTC
    Code Review
    .buildkite/collect-ipv6-e2e-logs.sh:1

    Could you share the specific IPv6 failures you encountered? Logs or a CI run link would be helpful. This script also collects several types of diagnostics beyond kind export logs. Could you also clarify how they are relate to the failures? Thanks.

    cursor[bot] cursor[bot] commented on code on Oct 17, 2026 11:07 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller.go:1
    @@ -1633,8 +1633,13 @@ func (r *RayClusterReconciler) createService(ctx context.Context, svc *corev1.Se
     func (r *RayClusterReconciler) createHeadPod(ctx context.Context, instance rayv1.RayCluster, clusterHash string) error {
     	logger := ctrl.LoggerFrom(ctx)
     
    +	headIPFamily, err := r.getHeadServiceIPFamily(ctx, &instance)
    +	if err != nil {
    +		return err
    +	}
    +
     	// build the pod then create it
    -	pod := r.buildHeadPod(ctx, instance)
    +	pod := r.buildHeadPod(ctx, instance, headIPFamily)

    Head pod creation races the service cache

    Medium Severity

    <!-- DESCRIPTION START -->
    createHeadPod now lists the head Service to decide dashboard-host before the Pod can be built. That list reads the informer cache, but reconcileHeadService just wrote the Service through the API server in the same loop. On first create the cache can still be empty, so getHeadServiceIPFamily errors and head Pod creation is skipped until a later reconcile. Previously the head Pod did not depend on that list.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: 74fdd368-e158-4477-8a53-861706cb19c8 -->

    <!-- LOCATIONS START
    ray-operator/controllers/ray/raycluster_controller.go#L1632-L1642
    ray-operator/controllers/ray/raycluster_controller.go#L2148-L2158
    LOCATIONS END -->
    <details>
    <summary>Additional Locations (1)</summary>

  • ray-operator/controllers/ray/raycluster_controller.go#L2148-L2158
  • </details>

    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjIwMGNjNjRkLWI2NjEtNDVmOC1iZDNiLTE1ZGFjMzE4ODNhMCIsImVuY3J5cHRpb25LZXkiOiJtRjk3NTZmcVRsRm85NG9GMFpEVjl1cTRjSlNSVjJMWGRlc2x1S3JXdERNIiwiYnJhbmNoIjoiZmVhdHVyZS9pcHY2LXN1cHBvcnQiLCJyZXBvT3duZXIiOiJyYXktcHJvamVjdCIsInJlcG9OYW1lIjoia3ViZXJheSIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjIwMGNjNjRkLWI2NjEtNDVmOC1iZDNiLTE1ZGFjMzE4ODNhMCIsImVuY3J5cHRpb25LZXkiOiJtRjk3NTZmcVRsRm85NG9GMFpEVjl1cTRjSlNSVjJMWGRlc2x1S3JXdERNIiwiYnJhbmNoIjoiZmVhdHVyZS9pcHY2LXN1cHBvcnQiLCJyZXBvT3duZXIiOiJyYXktcHJvamVjdCIsInJlcG9OYW1lIjoia3ViZXJheSIsInByTnVtYmVyIjo1MjE1LCJjb21taXRTaGEiOiI5Mjg4Y2NhMmEyZjE1NjVlNzVhZjEzM2EzYmExM2RhMGI0M2JmOWUyIiwicHJvdmlkZXIiOiJnaXRodWIifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>

    <sup>Reviewed by Cursor Bugbot for commit 9288cca2a2f1565e75af133a3ba13da0b43bf9e2. Configure here.</sup>

    cursor[bot] cursor[bot] commented on Oct 17, 2026 11:07 UTC
    Reviewer

    <!-- BUGBOT_REVIEW -->
    Cursor Bugbot has reviewed your changes and found 1 potential issue.

    <!-- BUGBOT_FIX_ALL -->
    <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTplYjQ2MWUwMy04MzNmLTQ0YzItOWNlYy1hZjI1OWZmZjRjMTciLCJlbmNyeXB0aW9uS2V5IjoiOGt5ZnVtaDhRZGp6UkFNQVZCOUhEVXhRT1dKbXVRTjFiQ0Z6eHN1ZWV0USIsImJyYW5jaCI6ImZlYXR1cmUvaXB2Ni1zdXBwb3J0IiwicmVwb093bmVyIjoicmF5LXByb2plY3QiLCJyZXBvTmFtZSI6Imt1YmVyYXkiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
    <!-- /BUGBOT_FIX_ALL -->

    <sup>Reviewed by Cursor Bugbot for commit 9288cca2a2f1565e75af133a3ba13da0b43bf9e2. Configure here.</sup>

    400Ping 400Ping commented on code on Oct 17, 2026 11:20 UTC
    Code Review
    .buildkite/collect-ipv6-e2e-logs.sh:1

    Sure, the failure was Buildkite build. TestRayClusterIPv6 timed out with the worker Pod stuck in Init forever.

  • Init container logs (kubectl logs --all-containers): the worker’s wait-gcs-ready kept failing to reach raycluster-ipv6-head-svc.<ns>.svc.cluster.local:6379. The operator log looked completely healthy, so without the init container output there was nothing to go on.

  • kind export logs (CoreDNS): repeated queries for raycluster-ipv6-head-svc.<ns>.svc.cluster.local.us-west-2.compute.internal. failing with dial udp <ipv4>:53: connect: network is unreachable. That was the root cause: the Buildkite host’s search us-west-2.compute.internal leaked into the kind node and every Pod (ndots:5), CoreDNS forwarded the host-suffix query to an IPv4 upstream that is unreachable from an IPv6-only Pod and returned SERVFAIL, and gRPC’s c-ares resolver aborts on SERVFAIL instead of retrying the bare name. Fixed in a949a25c by stripping the search domain from the node right after kind create cluster.

  • kubectl get pods -o wide and events: confirm the Pods actually got IPv6 addresses and which Pod is stuck in which init container. Cheap, and the first thing you look at.
  • The same init container logs also surfaced the second IPv6 bug in this PR: the old wait-for-tls-ip-san grep could never match an IPv6 SAN because openssl prints it uppercase and uncompressed.

    In an IPv4 kind cluster the forward succeeds (NXDOMAIN), so the other e2e jobs never hit this and the operator-log-only collection was enough for them. Now that the root cause is fixed, I’m fine either way: I can remove this file if you think it’s unnecessary, or make it a shared collector for all e2e jobs in a follow-up.

    justinyeh1995 justinyeh1995 commented on code on Oct 18, 2026 10:55 UTC
    Code Review
    .buildkite/collect-ipv6-e2e-logs.sh:1

    Thanks for the context. I'm fine keeping it in this PR since it only runs for this pr.

    justinyeh1995 justinyeh1995 commented on code on Oct 19, 2026 13:00 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_mtls_controller.go:1
    @@ -560,11 +561,31 @@ func certificateNeedsUpdate(existing, desired *certmanagerv1.CertificateSpec) bo
     		!setsEqual(existing.IPAddresses, desired.IPAddresses)
     }
     
    -// normalizeIPs returns a sorted, de-duplicated set of IPs. Always includes 127.0.0.1.
    +// normalizeIPs returns a sorted, de-duplicated set of IPs. It includes the
    +// loopback address for each Pod IP family so localhost is covered without
    +// rotating IPv4-only certificates merely because the operator was upgraded.
     func normalizeIPs(podIPs []string) []string {
     	s := sets.New(podIPs...)
     	s.Delete("")
    -	s.Insert("127.0.0.1")
    +	hasIPv4 := false
    +	hasIPv6 := false
    +	for _, podIP := range podIPs {
    +		ip := net.ParseIP(podIP)
    +		if ip == nil {
    +			continue
    +		}
    +		if ip.To4() != nil {
    +			hasIPv4 = true
    +		} else {
    +			hasIPv6 = true
    +		}
    +	}
    +	if hasIPv4 || (!hasIPv4 && !hasIPv6) {

    nit: maybe this reads clearer

    	if hasIPv4 || !hasIPv6 {
    

    justinyeh1995 justinyeh1995 approved these changes on Oct 19, 2026 13:39 UTC
    Approved Reviewer

    Overall LGTM. The pr description looks outdated. Can you also update the pr description to mention the dashboard-host is now derived from the head Service's IP family?

    400Ping 400Ping commented on Oct 21, 2026 06:14 UTC
    Author

    @machichima to do final pass

    machichima machichima commented on code on Nov 04, 2026 07:42 UTC
    Code Review
    ray-operator/controllers/ray/common/pod.go:1
    @@ -504,7 +504,9 @@ func configureTLS(podTemplate *corev1.PodTemplateSpec, instance rayv1.RayCluster
     	//     marks the worker dead, and the RayJob fails. Relying on KubeRay pod recreation is
     	//     not sufficient because the RayJob itself fails before a retry can succeed.
     	certPath := utils.RayTLSCertMountPath + "/tls.crt"
    +	caCertPath := utils.RayTLSCertMountPath + "/ca.crt"
     	waitScript := fmt.Sprintf(`CERT="%s"
    +CA_CERT="%s"

    Just FYI, I have a PR for supporting worker FQDN, after it's merged we do not need the wait-for-tls-ip-san init container, so we may not need this change

    https://github.com/kuberay-project/kuberay/pull/5191

    machichima machichima commented on code on Nov 04, 2026 07:50 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller.go:1
    @@ -1633,8 +1633,13 @@ func (r *RayClusterReconciler) createService(ctx context.Context, svc *corev1.Se
     func (r *RayClusterReconciler) createHeadPod(ctx context.Context, instance rayv1.RayCluster, clusterHash string) error {
     	logger := ctrl.LoggerFrom(ctx)
     
    +	headIPFamily, err := r.getHeadServiceIPFamily(ctx, &instance)
    +	if err != nil {
    +		return err
    +	}
    +
     	// build the pod then create it
    -	pod := r.buildHeadPod(ctx, instance)
    +	pod := r.buildHeadPod(ctx, instance, headIPFamily)

    Seems like a true issue, did you tested it?

    machichima machichima commented on code on Nov 04, 2026 07:56 UTC
    Code Review
    ray-operator/controllers/ray/common/job.go:1
    @@ -94,10 +94,10 @@ func BuildJobSubmitCommand(rayJobInstance *rayv1.RayJob, submissionMode rayv1.Jo
     	switch submissionMode {
     	case rayv1.SidecarMode:
     		// The sidecar submitter shares the same network namespace as the Ray dashboard,
    -		// so it uses 127.0.0.1 to connect to the Ray dashboard.
    +		// so it uses localhost, which resolves to the available IP family.
     		rayHeadContainer := rayJobInstance.Spec.RayClusterSpec.HeadGroupSpec.Template.Spec.Containers[utils.RayContainerIndex]
     		port = int(utils.FindContainerPort(&rayHeadContainer, utils.DashboardPortName, utils.DefaultDashboardPort))
    -		address = "http://127.0.0.1:" + strconv.Itoa(port)
    +		address = "http://localhost:" + strconv.Itoa(port)

    Using localhost will let the pod resolve it through its /etc/hosts. However, I think pods in an IPv6-only cluster also have 127.0.0.1 in that table. Could you please confirm that localhost resolves to the IPv6 address correctly in that case? Or can we directly put ::1 / 127.0.0.1 here based on the IP family?

    machichima machichima commented on code on Nov 04, 2026 08:15 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller.go:1
    @@ -1824,8 +1811,14 @@ func (r *RayClusterReconciler) buildWorkerPod(ctx context.Context, instance rayv
     func (r *RayClusterReconciler) buildRedisCleanupJob(ctx context.Context, instance rayv1.RayCluster) batchv1.Job {
     	logger := ctrl.LoggerFrom(ctx)
     
    -	// Build the head pod
    -	pod := r.buildHeadPod(ctx, instance)
    +	// Build the head pod. The Redis cleanup Job overwrites the container command, so the
    +	// dashboard-host default does not matter here; fall back to IPv4 if the head Service is gone.
    +	headIPFamily, err := r.getHeadServiceIPFamily(ctx, &instance)
    +	if err != nil {
    +		logger.Info("Head service not found while building the Redis cleanup Job, defaulting to IPv4", "error", err.Error())
    +		headIPFamily = corev1.IPv4Protocol
    +	}
    +	pod := r.buildHeadPod(ctx, instance, headIPFamily)

    If the dashboard-host does not matter, can we just use pod := r.buildHeadPod(ctx, instance, "")?

    400Ping 400Ping commented on code on Nov 06, 2026 07:03 UTC
    Code Review
    ray-operator/controllers/ray/raycluster_controller.go:1
    @@ -1633,8 +1633,13 @@ func (r *RayClusterReconciler) createService(ctx context.Context, svc *corev1.Se
     func (r *RayClusterReconciler) createHeadPod(ctx context.Context, instance rayv1.RayCluster, clusterHash string) error {
     	logger := ctrl.LoggerFrom(ctx)
     
    +	headIPFamily, err := r.getHeadServiceIPFamily(ctx, &instance)
    +	if err != nil {
    +		return err
    +	}
    +
     	// build the pod then create it
    -	pod := r.buildHeadPod(ctx, instance)
    +	pod := r.buildHeadPod(ctx, instance, headIPFamily)

    Reproduced it. In a burst of 120 RayClusters, 8 hit the cache miss and 4 briefly showed ReplicaFailure=True. Now the head Service is read from the API server on a cache miss, and 360 clusters over three bursts show no error.

    400Ping 400Ping commented on code on Nov 06, 2026 07:05 UTC
    Code Review
    ray-operator/controllers/ray/common/job.go:1
    @@ -94,10 +94,10 @@ func BuildJobSubmitCommand(rayJobInstance *rayv1.RayJob, submissionMode rayv1.Jo
     	switch submissionMode {
     	case rayv1.SidecarMode:
     		// The sidecar submitter shares the same network namespace as the Ray dashboard,
    -		// so it uses 127.0.0.1 to connect to the Ray dashboard.
    +		// so it uses localhost, which resolves to the available IP family.
     		rayHeadContainer := rayJobInstance.Spec.RayClusterSpec.HeadGroupSpec.Template.Spec.Containers[utils.RayContainerIndex]
     		port = int(utils.FindContainerPort(&rayHeadContainer, utils.DashboardPortName, utils.DefaultDashboardPort))
    -		address = "http://127.0.0.1:" + strconv.Itoa(port)
    +		address = "http://localhost:" + strconv.Itoa(port)

    Checked on an IPv6-only cluster. /etc/hosts has both ::1 and 127.0.0.1 for localhost, and the client tries ::1 first then falls back, so it works whether the server binds :: or 0.0.0.0.

    machichima machichima commented on Nov 09, 2026 03:39 UTC
    Contributor

    As a follow-up, we can run the whole e2e suite on an IPv6-only cluster in CI to make sure every feature works there, and use KUBERAY_TEST_IPV6=true as the switch. The CI can be triggered manually so that it won't block other PRs.

    In this PR, can you run manual test for ray job submit with IPv6 to ensure it works?

    400Ping 400Ping commented on Nov 14, 2026 01:38 UTC
    Author

    As a follow-up, we can run the whole e2e suite on an IPv6-only cluster in CI to make sure every feature works there, and use KUBERAY_TEST_IPV6=true as the switch. The CI can be triggered manually so that it won't block other PRs.

    > In this PR, can you run manual test for ray job submit with IPv6 to ensure it works?

    Sounds good, I'll open a follow-up to run the whole e2e suite on an IPv6-only cluster behind KUBERAY_TEST_IPV6=true with a manual trigger.

    For this PR I tested RayJob on an IPv6-only kind cluster (ipFamily: ipv6, kind v0.31.0, Kubernetes v1.35.0) with the operator built from this PR and rayproject/ray:2.58.0, in all three submission modes. The entrypoint runs 10 remote tasks and prints the node addresses. The command output below is trimmed to the relevant columns.

    $ kubectl get nodes -o wide
    NAME                STATUS  VERSION  INTERNAL-IP
    kind-control-plane  Ready   v1.35.0  fc00:f853:ccd:e793::2
    
    $ kubectl get rayjob -n rayjob-ipv6
    NAME           MODE          JOB STATUS   DEPLOYMENT STATUS   MESSAGE
    ipv6-http      HTTPMode      SUCCEEDED    Complete            Job finished successfully.
    ipv6-k8sjob    K8sJobMode    SUCCEEDED    Complete            Job finished successfully.
    ipv6-sidecar   SidecarMode   SUCCEEDED    Complete            Job finished successfully.
    
    $ kubectl get pods -n rayjob-ipv6 -o wide
    NAME                                         READY  STATUS     IP
    ipv6-http-m5w8c-head-jvl9w                   1/1    Running    fd00:10:244::21
    ipv6-http-m5w8c-small-group-worker-jrf2x     1/1    Running    fd00:10:244::22
    ipv6-k8sjob-k4gdt                            0/1    Completed  fd00:10:244::25
    ipv6-k8sjob-lfjc9-head-lpchv                 1/1    Running    fd00:10:244::1f
    ipv6-k8sjob-lfjc9-small-group-worker-z4zg9   1/1    Running    fd00:10:244::20
    ipv6-sidecar-p8qjh-head-zbkmb                1/2    NotReady   fd00:10:244::23
    ipv6-sidecar-p8qjh-small-group-worker-lhk87  1/1    Running    fd00:10:244::24
    

    All head Pods were started with --dashboard-host=:: and every head Service has ipFamilies: [IPv6]. The sidecar head Pod shows 1/2 NotReady only because its submitter container has already completed.

    <details>
    <summary>K8sJobMode, <code>kubectl logs job/ipv6-k8sjob</code> (submits through the head Service)</summary>

    2026-11-13 17:29:34,876	INFO cli.py:42 -- Job submission server address: http://ipv6-k8sjob-lfjc9-head-svc.rayjob-ipv6.svc.cluster.local:8265
    2026-11-13 17:29:35,329	SUCC cli.py:66 -- ----------------------------------------------
    2026-11-13 17:29:35,329	SUCC cli.py:67 -- Job 'ipv6-k8sjob-6rmjg' submitted successfully
    2026-11-13 17:29:35,329	SUCC cli.py:68 -- ----------------------------------------------
    2026-11-13 17:29:35,329	INFO cli.py:330 -- Next steps
    2026-11-13 17:29:35,329	INFO cli.py:331 -- Query the logs of the job:
    2026-11-13 17:29:35,329	INFO cli.py:333 -- ray job logs ipv6-k8sjob-6rmjg
    2026-11-13 17:29:35,329	INFO cli.py:335 -- Query the status of the job:
    2026-11-13 17:29:35,329	INFO cli.py:337 -- ray job status ipv6-k8sjob-6rmjg
    2026-11-13 17:29:35,329	INFO cli.py:339 -- Request the job to be stopped:
    2026-11-13 17:29:35,329	INFO cli.py:341 -- ray job stop ipv6-k8sjob-6rmjg
    2026-11-13 17:29:38,892	INFO cli.py:42 -- Job submission server address: http://ipv6-k8sjob-lfjc9-head-svc.rayjob-ipv6.svc.cluster.local:8265
    2026-11-13 17:29:35,117	INFO job_manager.py:583 -- Runtime env is setting up.
    Running entrypoint for job ipv6-k8sjob-6rmjg: python /home/ray/samples/job.py
    2026-11-13 17:29:36,162	INFO worker.py:1683 -- Using address [fd00:10:244::1f]:6379 set in the environment variable RAY_ADDRESS
    2026-11-13 17:29:36,164	INFO worker.py:1833 -- Connecting to existing Ray cluster at address: [fd00:10:244::1f]:6379...
    2026-11-13 17:29:36,175	INFO worker.py:2015 -- Connected to Ray cluster. View the dashboard at http://[fd00:10:244::1f]:8265 
    result 285
    nodes ['fd00:10:244::1f', 'fd00:10:244::20']
    2026-11-13 17:29:43,911	INFO sdk.py:520 -- WebSocket closed for job ipv6-k8sjob-6rmjg with close code 1000
    2026-11-13 17:29:43,917	SUCC cli.py:66 -- ---------------------------------
    2026-11-13 17:29:43,917	SUCC cli.py:67 -- Job 'ipv6-k8sjob-6rmjg' succeeded
    2026-11-13 17:29:43,917	SUCC cli.py:68 -- ---------------------------------
    

    </details>

    <details>
    <summary>SidecarMode, <code>kubectl logs &lt;head pod&gt; -c ray-job-submitter</code> (submits through <code>http://localhost:8265</code>)</summary>

    Waiting for Ray Dashboard GCS to become healthy at http://localhost:8265 ...
    Waiting for Ray Dashboard GCS to become healthy at http://localhost:8265 ...
    Waiting for Ray Dashboard GCS to become healthy at http://localhost:8265 ...
    Waiting for Ray Dashboard GCS to become healthy at http://localhost:8265 ...
    2026-11-13 17:29:19,770	INFO cli.py:42 -- Job submission server address: http://localhost:8265
    2026-11-13 17:29:20,274	SUCC cli.py:66 -- -----------------------------------------------
    2026-11-13 17:29:20,274	SUCC cli.py:67 -- Job 'ipv6-sidecar-4xbrg' submitted successfully
    2026-11-13 17:29:20,274	SUCC cli.py:68 -- -----------------------------------------------
    2026-11-13 17:29:20,274	INFO cli.py:330 -- Next steps
    2026-11-13 17:29:20,274	INFO cli.py:331 -- Query the logs of the job:
    2026-11-13 17:29:20,274	INFO cli.py:333 -- ray job logs ipv6-sidecar-4xbrg
    2026-11-13 17:29:20,274	INFO cli.py:335 -- Query the status of the job:
    2026-11-13 17:29:20,274	INFO cli.py:337 -- ray job status ipv6-sidecar-4xbrg
    2026-11-13 17:29:20,274	INFO cli.py:339 -- Request the job to be stopped:
    2026-11-13 17:29:20,274	INFO cli.py:341 -- ray job stop ipv6-sidecar-4xbrg
    2026-11-13 17:29:21,370	INFO cli.py:42 -- Job submission server address: http://localhost:8265
    2026-11-13 17:29:20,043	INFO job_manager.py:583 -- Runtime env is setting up.
    Running entrypoint for job ipv6-sidecar-4xbrg: bash -c 'sleep 60 && python /home/ray/samples/job.py'
    2026-11-13 17:30:26,010	INFO worker.py:1683 -- Using address [fd00:10:244::23]:6379 set in the environment variable RAY_ADDRESS
    2026-11-13 17:30:26,012	INFO worker.py:1833 -- Connecting to existing Ray cluster at address: [fd00:10:244::23]:6379...
    2026-11-13 17:30:26,023	INFO worker.py:2015 -- Connected to Ray cluster. View the dashboard at http://[fd00:10:244::23]:8265 
    result 285
    nodes ['fd00:10:244::23', 'fd00:10:244::24']
    2026-11-13 17:30:30,371	INFO sdk.py:520 -- WebSocket closed for job ipv6-sidecar-4xbrg with close code 1000
    2026-11-13 17:30:30,374	SUCC cli.py:66 -- ----------------------------------
    2026-11-13 17:30:30,374	SUCC cli.py:67 -- Job 'ipv6-sidecar-4xbrg' succeeded
    2026-11-13 17:30:30,374	SUCC cli.py:68 -- ----------------------------------
    

    </details>

    <details>
    <summary>HTTPMode, <code>ray job logs ipv6-http-4p7mk</code> from the head Pod (the operator submits through the dashboard HTTP API, there is no submitter)</summary>

    2026-11-13 17:30:42,890	INFO cli.py:42 -- Job submission server address: http://[fd00:10:244::21]:8265
    2026-11-13 17:30:42,898	INFO cli.py:569 -- 2026-11-13 17:29:28,690	INFO job_manager.py:583 -- Runtime env is setting up.
    Running entrypoint for job ipv6-http-4p7mk: python /home/ray/samples/job.py
    2026-11-13 17:29:29,743	INFO worker.py:1683 -- Using address [fd00:10:244::21]:6379 set in the environment variable RAY_ADDRESS
    2026-11-13 17:29:29,745	INFO worker.py:1833 -- Connecting to existing Ray cluster at address: [fd00:10:244::21]:6379...
    2026-11-13 17:29:29,755	INFO worker.py:2015 -- Connected to Ray cluster. View the dashboard at http://[fd00:10:244::21]:8265 
    result 285
    nodes ['fd00:10:244::21', 'fd00:10:244::22']
    

    </details>

    The SidecarMode entrypoint has a sleep 60 in front. A SidecarMode job that finishes within a few seconds can leave the RayJob stuck in Initializing, because the submitter exits before the RayCluster is first Ready.

    Reviewers
    Assignees
    400Ping 400Ping
    Labels
    risk: low confidence: 89.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 83.5% (HIGH) · Higher = larger blast radius
    83.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.8% · Lower = rushed or shallow review
    89.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 8.5% · Safe to merge
    8.5%