Skip to content

Add fqdn - #5108

Open
AlterHoodie wants to merge 2 commits into
ray-project:masterfrom
AlterHoodie:add-fqdn
Open

Add fqdn#5108
AlterHoodie wants to merge 2 commits into
ray-project:masterfrom
AlterHoodie:add-fqdn

Conversation

@AlterHoodie

Copy link
Copy Markdown
Contributor

Why are these changes needed?

Ray worker Pods are only addressable by Pod IP today, and that IP changes whenever a Pod is recreated. This PR sets worker hostname / subdomain from replica (and host - for multihost) indices and always creates the RayCluster headless Service so each worker gets a stable Pod FQDN that can survive recreates.

Hostname/subdomain assignment still sits behind RayMultiHostIndexing, since that is where replica indices are assigned. Creating the headless Service is no longer limited to multi-host groups (NumOfHosts > 1).

That stretches the meaning of RayMultiHostIndexing. Looking for guidance on whether to:

  1. Add a separate feature flag for worker FQDNs / always-on headless Service alongside RayMultiHostIndexing, or
  2. Keep this approach: headless Service by default for all worker groups, hostname/subdomain still tied to RayMultiHostIndexing (default on).

Note: The multi_host e2e test has been extended to support FQDN verification , depending on above decision will split into its own e2e test.

Related issue number

Closes #5000

Checks

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

Manual test instructions

  1. Build/deploy operator with this change (./hack/local_deploy.sh or equivalent) and ensure RayMultiHostIndexing=true.
  2. Apply a sample cluster:
    kubectl apply -f ray-operator/config/samples/ray-cluster.sample.yaml
  3. Confirm worker hostname/subdomain and headless Service:
    kubectl get svc | grep headless
    kubectl get pods -l ray.io/node-type=worker -o custom-columns=\
    NAME:.metadata.name,HOSTNAME:.spec.hostname,SUBDOMAIN:.spec.subdomain,IP:.status.podIP
  4. DNS lookup:
    kubectl run dnscheck --rm --restart=Never --image=busybox:1.36 --attach -- \
      nslookup workergroup-0.raycluster-kuberay-headless.default.svc.cluster.local
  5. Delete the worker Pod and confirm the replacement keeps the same hostname/FQDN with a new IP/UID.
  6. Unit tests:
    cd ray-operator
    go test ./controllers/ray/common/ -run TestDeafultWorkerPodTemplateWithReplicaGrpAndIndex -count=1
    go test ./controllers/ray/ -run TestReconcileHeadlessService -count=1
  7. E2E (operator image must include this change):
    cd ray-operator
    go test -timeout 30m -v ./test/e2e -run TestRayClusterSingleHostMultiSlice
    go test -timeout 60m -v ./test/e2e -run TestRayClusterMultiHostMultiSlice

Always create the headless Service and set worker Pod hostname/subdomain
from replica indices so workers keep a stable DNS name across recreates.
Hostname assignment stays behind RayMultiHostIndexing.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 0b6dd32. Configure here.

hostname = fmt.Sprintf("%s-%d", groupName, replicaIndex)
}
return utils.CheckLabel(hostname)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Invalid DNS worker hostnames

High Severity

generateWorkerHostname builds pod.spec.hostname from raw groupName and only runs CheckLabel, which does not enforce DNS-1123 rules. Worker groupName values may include uppercase or _ today, and with RayMultiHostIndexing defaulting on those pods are rejected on create. Existing clusters that previously worked can stop reconciling workers.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0b6dd32. Configure here.

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.

[Feature] Support Pod FQDNs via pod.spec.hostname

1 participant