-
Notifications
You must be signed in to change notification settings - Fork 662
[Feat] Add Ray Cron Job #4159
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
base: master
Are you sure you want to change the base?
[Feat] Add Ray Cron Job #4159
Conversation
| func constructRayJob(cronJob *rayv1.RayCronJob) *rayv1.RayJob { | ||
| rayJob := &rayv1.RayJob{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: fmt.Sprintf("%s-%s", cronJob.Name, rand.String(5)), | ||
| Namespace: cronJob.Namespace, | ||
| Labels: map[string]string{ | ||
| "ray.io/cronjob-name": cronJob.Name, | ||
| }, | ||
| }, | ||
| Spec: *cronJob.Spec.JobTemplate.DeepCopy(), | ||
| } | ||
| return rayJob | ||
| } |
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 think we should set an OwnerReference in order to do the garbage collection by k8s.
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.
Yes! Just added. Thank you for pointing this out!
| // RayCronJob is the Schema for the raycronjobs API | ||
| type RayCronJob struct { | ||
| metav1.TypeMeta `json:",inline"` | ||
| Spec RayCronJobSpec `json:"spec,omitempty"` | ||
| Status RayCronJobStatus `json:"status,omitempty"` | ||
| metav1.ObjectMeta `json:"metadata,omitempty"` | ||
| } |
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 think we should keep TypeMeta and ObjectMeta at the top, with Spec and Status grouped below.
kuberay/ray-operator/apis/ray/v1/raycluster_types.go
Lines 378 to 387 in 32c1d1b
type RayCluster struct { // Standard object metadata. metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` // Specification of the desired behavior of the RayCluster. Spec RayClusterSpec `json:"spec,omitempty"` // +optional Status RayClusterStatus `json:"status,omitempty"` } kuberay/ray-operator/apis/ray/v1/rayservice_types.go
Lines 219 to 225 in 32c1d1b
type RayService struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` Spec RayServiceSpec `json:"spec,omitempty"` // +optional Status RayServiceStatuses `json:"status,omitempty"` }
| // The overall state of the RayCronJob. | ||
| type ScheduleStatus string | ||
|
|
||
| const ( | ||
| StatusNew ScheduleStatus = "" | ||
| StatusScheduled ScheduleStatus = "Scheduled" | ||
| StatusValidationFailed ScheduleStatus = "ValidationFailed" | ||
| ) |
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 haven’t seen ScheduleStatus being used anywhere yet. Is this something that will be added later?
| type RayCronJobSpec struct { | ||
| // JobTemplate defines the job spec that will be created by cron scheduling | ||
| JobTemplate *RayJobSpec `json:"jobTemplate"` | ||
| // Schedule is the cron schedule string | ||
| Schedule string `json:"schedule"` | ||
| } |
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.
Not sure if this is alright, but I think we should introduce a separate struct (e.g. RayJobTemplateSpec) to hold both the metadata and the spec for the generated RayJob, similar to how Kubernetes models JobTemplateSpec in CronJob.
This would allow users to specify metadata inside jobTemplate, which we can then propagate to the created RayJob. It also keeps the API aligned with common Kubernetes patterns.
WDYT?
Why are these changes needed?
Support cron job scheduling. Following this design docs and implement milestone 1 in this PR
Main changes:
RayCronJobCRD and controllerRayCronJobTest
Apply the sample YAML
ray-operator/config/samples/ray-cronjob.sample.yaml. RayJobs are being scheduled every minute:Trigger validation error
Related issue number
Following comment: #2426 (comment)
Closes #2426
Checks