kuberay icon indicating copy to clipboard operation
kuberay copied to clipboard

Ray pod name is unexpectedly cut off by Kuberay

Open Yicheng-Lu-llll opened this issue 1 year ago • 0 comments

Why are these changes needed?

When running RayService examples under the sample dir, the Ray Pod name may be unexpectedly truncated by KubeRay, although the name meets all naming rules listed in the Kubernetes documentation. See below for an example:

# Run a Rayservice sample in under https://github.com/ray-project/kuberay/tree/master/ray-operator/config/samples
kubectl apply -f /home/ubuntu/kuberay/ray-operator/config/samples/ray-service.sample.yaml
kubectl get pod
# NAME                                                      READY   STATUS    RESTARTS   AGE
# ervice-sample-raycluster-bpv6l-worker-small-group-5xnlb   1/1     Running   0          6m16s
# kuberay-operator-5987588ffc-qkhgs                         1/1     Running   0          63m
# rayservice-sample-raycluster-bpv6l-head-22sgg             1/1     Running   0          6m16s

According to the method KubeRay uses to create the Pod name, the worker Pod name should be rayservice-sample-raycluster-bpv6l-worker-small-group-5xnlb. This name should not be truncated, as its length is 59, which is smaller than the maximum length allowed by Kubernetes (63 characters).

Kubray uses checkName to make sure the name is valid, however, the function and its usage has problem. the checkName assumes it:

  1. Only check the generated name as it subtracts 5 from MaxNameLength. The 5 represents the length of random characters generated by Kubernetes. See the related Kubernetes code here.
  2. Only check the Pod name as there are some naming assumptions for Pod names, but the usage of this function also applies to services, routes, ingresses, and service accounts.

This PR makes the checkName function general enough to check names of all types, and it utilizes the new function CheckGenerateName to verify GenerateName.

Related issue number

Checks

# Run a Rayservice sample in under https://github.com/ray-project/kuberay/tree/master/ray-operator/config/samples
kubectl apply -f /home/ubuntu/kuberay/ray-operator/config/samples/ray-service.sample.yaml
kubectl get pod
# NAME                                                          READY   STATUS    RESTARTS   AGE
# kuberay-operator-5987588ffc-skw4f                             1/1     Running   0          94s
# rayservice-sample-raycluster-wldcv-head-lcwt5                 1/1     Running   0          81s
# rayservice-sample-raycluster-wldcv-worker-small-group-54q2q   1/1     Running   0          81s

Yicheng-Lu-llll avatar Jan 26 '24 15:01 Yicheng-Lu-llll