-
Notifications
You must be signed in to change notification settings - Fork 321
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
Add ray.io/originated-from
labels
#1830
Conversation
ray.io/originated-from-name
and ray.io/originated-from-type
labels
9caa2d8
to
c3e0a56
Compare
apiserver/pkg/util/config.go
Outdated
@@ -13,7 +13,8 @@ const ( | |||
RayClusterUserLabelKey = "ray.io/user" | |||
RayClusterVersionLabelKey = "ray.io/version" | |||
RayClusterEnvironmentLabelKey = "ray.io/environment" | |||
RayServiceLabelKey = "ray.io/service" | |||
RayOriginatedFromNameLabelKey = "ray.io/originated-from-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.
ray.io/owner-name
might be better?
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.
We have considered using owner-name
. The question is that RayJob/RayService owns RayCluster, and RayCluster owns Ray Pods. We may need to associate the Ray Pods from both the RayJob/RayService level and the RayCluster level.
We don't have a good idea for the label name to represent the "root" of the owner/dependent tree. Do you have any good ideas?
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.
We don't have a good idea for the label name to represent the "root" of the owner/dependent tree. Do you have any good ideas?
Would it be simpler to just have a single label ray.io/originiated-from
that contains both the type and name?
ray.io/originated-from: rayjob/myjob
ray.io/originated-from: raycluster/mycluster
ray.io/originated-from: rayservice/myservice
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.
It sounds good to me. cc @rueian WDYT?
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.
That is a great idea. However, k8s will reject /
in label value with an error like this:
metadata.labels: Invalid value: "rayjob/myjob": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')
How about using .
instead?
ray.io/originated-from: rayjob.myjob
ray.io/originated-from: raycluster.mycluster
ray.io/originated-from: rayservice.myservice
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.
Is it possible for CR name to have .
? If it is impossible, using .
makes sense to me.
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.
Unfortunately, .
is allowed in resource names, but _
is not.
So we are safe to use the following:
ray.io/originated-from: rayjob_myjob
ray.io/originated-from: raycluster_mycluster
ray.io/originated-from: rayservice_myservice
Does this sound good to you @andrewsykim @kevin85421?
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.
Unfortunately,
.
is allowed in resource names, but_
is not.
The use of _
sounds good to me. What's the regex for resource names?
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 one [a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*
apiserver/pkg/util/config.go
Outdated
@@ -13,7 +13,8 @@ const ( | |||
RayClusterUserLabelKey = "ray.io/user" | |||
RayClusterVersionLabelKey = "ray.io/version" | |||
RayClusterEnvironmentLabelKey = "ray.io/environment" | |||
RayServiceLabelKey = "ray.io/service" | |||
RayOriginatedFromNameLabelKey = "ray.io/originated-from-name" | |||
RayOriginatedFromTypeLabelKey = "ray.io/originated-from-type" |
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.
ray.io/owner-resource
?
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.
As @kevin85421 mentioned, we prefer not to use the term owner
as it frequently sets incorrect expectations.
562455c
to
68e76ea
Compare
ray.io/originated-from-name
and ray.io/originated-from-type
labelsray.io/originated-from
labels
@@ -75,7 +75,10 @@ const ( | |||
ComponentName = "kuberay-operator" | |||
|
|||
// The defaule RayService Identifier. |
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.
Could we use CRDType
instead?
type CRDType string |
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.
Sure.
bcc974e
to
9714100
Compare
@rueian could you rebase with the master branch? Thanks! |
9714100
to
53cc42c
Compare
Hi @kevin85421, rebased! |
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.
-
Could you summarize the current status of the
ray.io/originated-from
label? For instance, which Kubernetes resources will have this label if I create a RayService, RayJob, or RayCluster at this moment? -
The tests are scattered across multiple locations. In the future, we may need to devise a better method for testing label propagations if we find them hard to maintain.
@@ -154,3 +155,16 @@ const ( | |||
HeadService ServiceType = "headService" | |||
ServingService ServiceType = "serveService" | |||
) | |||
|
|||
// RayOriginatedFromServiceLabelValue generates a RayService value for the label RayOriginatedFromLabelKey |
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.
Will it be better if we unify the two functions RayOriginatedFromServiceLabelValue
and RayOriginatedFromJobLabelValue
into a single function?
func FUNC_NAME(crdType CRDType, crName string) string {
return string(crdType) + "_" + crName
}
// BuildRouteForRayService Builds the route for head service dashboard for RayService. | ||
// This is used to expose dashboard for external traffic. | ||
// RayService controller updates the ingress whenever a new RayCluster serves the traffic. | ||
func BuildRouteForRayService(service rayv1.RayService, cluster rayv1.RayCluster) (*routev1.Route, error) { |
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 function is not used anywhere.
@@ -589,7 +589,7 @@ func setContainerEnvVars(pod *corev1.Pod, rayNodeType rayv1.RayNodeType, rayStar | |||
container.Env = append(container.Env, portEnv) | |||
} | |||
|
|||
if strings.ToLower(creator) == utils.RayServiceCreatorLabelValue { | |||
if strings.EqualFold(creator, string(utils.RayServiceCRD)) { |
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.
EqualFold reports whether s and t, interpreted as UTF-8 strings, are equal under simple Unicode case-folding, which is a more general form of case-insensitity.
This makes the linter happy.
// RayOriginatedFromLabelKey is the label used to associate the root KubeRay Custom Resource. | ||
// For example, if a RayCluster is created by a RayJob named myjob, then the cluster will have | ||
// A ray.io/originated-from=RayService_mysvc label will be added to the following resources if they are originated from a RayService mysvc. | ||
// * Kubernetes Services | ||
// * RayClusters | ||
// A ray.io/originated-from=RayJob_myjob label will be added to the following resources if they are originated from a RayJob myjob. | ||
// * Kubernetes Jobs | ||
// * RayClusters |
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.
Bulletin where the ray.io/originated-from
will show up.
Would you mind rebasing with the master branch? Thanks! |
…s created by RayJob
…from-*` labels on k8s resources created by RayService
…from` labels on k8s resources created by RayService
90b0a20
to
780abbe
Compare
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.
I still have some comments for this PR, but since it has been pending for a while, I'll merge it now and immediately open a follow-up PR to address those comments.
Why are these changes needed?
Previously, we didn't have a label for querying resources, such as the underlying ray cluster, created by a RayJob, while we had the
ray.io/service
label for querying resources created by a RayService.We could introduce a new
ray.io/job
label for this purpose, and that would result in having three labels that look similar:ray.io/job
ray.io/service
ray.io/cluster
However, the current usage of the
ray.io/cluster
label differs greatly from the first two.After a discussion with @kevin85421, we think we could clarify the usage of the first two by replacing them with the following labels:
ray.io/originated-from-name
ray.io/originated-from-type
Examples:
To summarize, this PR removes the existing
ray.io/service
label and introducesray.io/originated-from-name
andray.io/originated-from-type
for both clarifying and unifying how to query resources created by a RayJob or a RayService.Additionally, to make us more confident that
ray.io/service
is removable, I have searched its usage on GitHub and found that no one else uses this label.Related issue number
Checks