Skip to content

Commit

Permalink
Make k8s job backoff limit configurable for RayJob (#2091)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjyao authored May 1, 2024
1 parent 33a9b24 commit 9662bd9
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 1 deletion.
15 changes: 15 additions & 0 deletions docs/reference/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ _Appears in:_
| `entrypointNumCpus` _float_ | EntrypointNumCpus specifies the number of cpus to reserve for the entrypoint command. |
| `entrypointNumGpus` _float_ | EntrypointNumGpus specifies the number of gpus to reserve for the entrypoint command. |
| `entrypointResources` _string_ | EntrypointResources specifies the custom resources and quantities to reserve for the entrypoint command. |
| `submitterConfig` _[SubmitterConfig](#submitterconfig)_ | Configurations of submitter k8s job. |



Expand Down Expand Up @@ -214,6 +215,20 @@ _Appears in:_
| `workersToDelete` _string array_ | WorkersToDelete workers to be deleted |


#### SubmitterConfig





_Appears in:_
- [RayJobSpec](#rayjobspec)

| Field | Description |
| --- | --- |
| `backoffLimit` _integer_ | BackoffLimit of the submitter k8s job. |


#### UpscalingMode

_Underlying type:_ _string_
Expand Down
6 changes: 6 additions & 0 deletions helm-chart/kuberay-operator/crds/ray.io_rayjobs.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions ray-operator/apis/ray/v1/rayjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const (
HTTPMode JobSubmissionMode = "HTTPMode" // Submit job via HTTP request
)

type SubmitterConfig struct {
// BackoffLimit of the submitter k8s job.
BackoffLimit *int32 `json:"backoffLimit,omitempty"`
}

// RayJobSpec defines the desired state of RayJob
type RayJobSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Expand Down Expand Up @@ -104,6 +109,8 @@ type RayJobSpec struct {
// EntrypointResources specifies the custom resources and quantities to reserve for the
// entrypoint command.
EntrypointResources string `json:"entrypointResources,omitempty"`
// Configurations of submitter k8s job.
SubmitterConfig *SubmitterConfig `json:"submitterConfig,omitempty"`
}

// RayJobStatus defines the observed state of RayJob
Expand Down
25 changes: 25 additions & 0 deletions ray-operator/apis/ray/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ray-operator/config/crd/bases/ray.io_rayjobs.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion ray-operator/controllers/ray/rayjob_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ func (r *RayJobReconciler) getSubmitterTemplate(ctx context.Context, rayJobInsta
// createNewK8sJob creates a new Kubernetes Job. It returns an error.
func (r *RayJobReconciler) createNewK8sJob(ctx context.Context, rayJobInstance *rayv1.RayJob, submitterTemplate corev1.PodTemplateSpec) error {
logger := ctrl.LoggerFrom(ctx)
submitterBackoffLimit := pointer.Int32(2)
if rayJobInstance.Spec.SubmitterConfig != nil && rayJobInstance.Spec.SubmitterConfig.BackoffLimit != nil {
submitterBackoffLimit = rayJobInstance.Spec.SubmitterConfig.BackoffLimit
}
job := &batchv1.Job{
ObjectMeta: metav1.ObjectMeta{
Name: rayJobInstance.Name,
Expand All @@ -437,7 +441,7 @@ func (r *RayJobReconciler) createNewK8sJob(ctx context.Context, rayJobInstance *
// is attempted 3 times at the maximum, but still mitigates the case of unrecoverable
// application-level errors, where the maximum number of retries is reached, and the job
// completion time increases with no benefits, but wasted resource cycles.
BackoffLimit: pointer.Int32(2),
BackoffLimit: submitterBackoffLimit,
Template: submitterTemplate,
},
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ray-operator/pkg/client/applyconfiguration/utils.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9662bd9

Please sign in to comment.