Skip to content
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

Merged
merged 5 commits into from
Jan 23, 2024

Conversation

rueian
Copy link
Contributor

@rueian rueian commented Jan 11, 2024

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:

# rayjob
ray.io/originated-from-name: myjob
ray.io/originated-from-type: rayjob
# rayservice
ray.io/originated-from-name: myservice
ray.io/originated-from-type: rayservice

To summarize, this PR removes the existing ray.io/service label and introduces ray.io/originated-from-name and ray.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

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

@rueian rueian changed the title Originated labels Add ray.io/originated-from-name and ray.io/originated-from-type labels Jan 11, 2024
@@ -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"
Copy link
Contributor

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?

Copy link
Member

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?

Copy link
Contributor

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

Copy link
Member

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?

Copy link
Contributor Author

@rueian rueian Jan 13, 2024

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

Copy link
Member

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.

Copy link
Contributor Author

@rueian rueian Jan 14, 2024

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?

Copy link
Member

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?

Copy link
Contributor Author

@rueian rueian Jan 15, 2024

Choose a reason for hiding this comment

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

@@ -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"
Copy link
Contributor

Choose a reason for hiding this comment

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

ray.io/owner-resource?

Copy link
Contributor Author

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.

@kevin85421 kevin85421 self-assigned this Jan 11, 2024
@rueian rueian force-pushed the originated-labels branch 5 times, most recently from 562455c to 68e76ea Compare January 14, 2024 11:14
@rueian rueian changed the title Add ray.io/originated-from-name and ray.io/originated-from-type labels Add ray.io/originated-from labels Jan 15, 2024
@@ -75,7 +75,10 @@ const (
ComponentName = "kuberay-operator"

// The defaule RayService Identifier.
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure.

apiserver/pkg/util/config.go Outdated Show resolved Hide resolved
ray-operator/controllers/ray/utils/constant.go Outdated Show resolved Hide resolved
@rueian rueian force-pushed the originated-labels branch 2 times, most recently from bcc974e to 9714100 Compare January 17, 2024 14:52
@kevin85421
Copy link
Member

@rueian could you rebase with the master branch? Thanks!

@rueian
Copy link
Contributor Author

rueian commented Jan 19, 2024

@rueian could you rebase with the master branch? Thanks!

Hi @kevin85421, rebased!

Copy link
Member

@kevin85421 kevin85421 left a comment

Choose a reason for hiding this comment

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

  1. 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?

  2. 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
Copy link
Member

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) {
Copy link
Contributor Author

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.

apiserver/pkg/util/service.go Show resolved Hide resolved
@@ -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)) {
Copy link
Contributor Author

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.

Comment on lines +9 to +16
// 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
Copy link
Contributor Author

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.

@kevin85421
Copy link
Member

Would you mind rebasing with the master branch? Thanks!

Copy link
Member

@kevin85421 kevin85421 left a 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.

@kevin85421 kevin85421 merged commit f05fa2e into ray-project:master Jan 23, 2024
18 of 24 checks passed
ryanaoleary pushed a commit to ryanaoleary/kuberay that referenced this pull request Feb 13, 2024
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.

None yet

3 participants