-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] validate the name length of RayCluster, RayService, and RayJob #3083
base: master
Are you sure you want to change the base?
Conversation
1032d24
to
5cd981c
Compare
d465e97
to
b24ba93
Compare
@@ -15,7 +15,7 @@ import ( | |||
func BuildRouteForHeadService(cluster rayv1.RayCluster) (*routev1.Route, error) { | |||
labels := map[string]string{ | |||
utils.RayClusterLabelKey: cluster.Name, | |||
utils.RayIDLabelKey: utils.GenerateIdentifier(cluster.Name, rayv1.HeadNode), | |||
utils.RayIDLabelKey: utils.CheckLabel(utils.GenerateIdentifier(cluster.Name, rayv1.HeadNode)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an old bug that forgets to chunk the value for utils.RayIDLabelKey
.
@@ -21,7 +21,7 @@ func BuildIngressForHeadService(ctx context.Context, cluster rayv1.RayCluster) ( | |||
|
|||
labels := map[string]string{ | |||
utils.RayClusterLabelKey: cluster.Name, | |||
utils.RayIDLabelKey: utils.GenerateIdentifier(cluster.Name, rayv1.HeadNode), | |||
utils.RayIDLabelKey: utils.CheckLabel(utils.GenerateIdentifier(cluster.Name, rayv1.HeadNode)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an old bug that forgets to chunk the value for utils.RayIDLabelKey
.
@@ -21,7 +22,7 @@ const ( | |||
redisAddress = "redis:6379" | |||
) | |||
|
|||
func TestRayClusterGCSFaultTolerence(t *testing.T) { | |||
func TestRayClusterGCSFaultTolerance(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix typo.
e6ee5ac
to
8817876
Compare
3426bc8
to
e26affb
Compare
@@ -1019,8 +1019,6 @@ func (r *RayClusterReconciler) createHeadRoute(ctx context.Context, route *route | |||
func (r *RayClusterReconciler) createService(ctx context.Context, svc *corev1.Service, instance *rayv1.RayCluster) error { | |||
logger := ctrl.LoggerFrom(ctx) | |||
|
|||
// making sure the name is valid | |||
svc.Name = utils.CheckName(svc.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more utils.CheckName
to cut service names.
return CheckName(fmt.Sprintf("%s-%s-%s", ownerName, rayv1.HeadNode, "svc")), nil | ||
return fmt.Sprintf("%s-%s-%s", ownerName, rayv1.HeadNode, "svc"), nil | ||
case RayClusterCRD: | ||
headSvcName := CheckName(fmt.Sprintf("%s-%s-%s", ownerName, rayv1.HeadNode, "svc")) | ||
headSvcName := fmt.Sprintf("%s-%s-%s", ownerName, rayv1.HeadNode, "svc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more utils.CheckName
to cut service names.
@@ -293,7 +293,7 @@ func ExtractRayIPFromFQDN(fqdnRayIP string) string { | |||
|
|||
// GenerateServeServiceName generates name for serve service. | |||
func GenerateServeServiceName(serviceName string) string { | |||
return CheckName(fmt.Sprintf("%s-%s-%s", serviceName, ServeName, "svc")) | |||
return fmt.Sprintf("%s-%s-%s", serviceName, ServeName, "svc") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more utils.CheckName
to cut service names.
e26affb
to
c9c3e9c
Compare
Signed-off-by: Rueian <[email protected]>
c9c3e9c
to
78f39a2
Compare
Would it be useful to also validate in webhooks like here? kuberay/ray-operator/pkg/webhooks/v1/raycluster_webhook.go Lines 79 to 84 in 6c4a77d
These webhooks can optionally be enabled by user (disabled by default). They prevent creation of invalid resources with a more obvious error than the controller events. |
Why are these changes needed?
Part of the #3076, adding length validation to RayCluster, RayService, and RayJob to make sure we don't cut k8s service names:
53 characters
at most.47 characters
at most.47 characters
at most.After #3101, the longest suffix for a K8s service is now "-serve-svc", which takes 10 characters. Therefore, we can only use 63-10=53 characters for the name of a RayCluster.
After #3102, we now add a "-" and 5 random characters to the name of either RayService or RayJob to create the underlying RayCluster. Therefore, they can only have 53-6=47 characters for their name.
Any RayCluster, RayService, or RayJob with a name exceeding the above limit will not be reconciled further and will receive an invalid spec event, which can be observed by
kubectl describe
.Related issue number
Checks