Skip to content

[V2][Ray] Make KubeRay submission mode configurable - #7799

Open
davidlin20dev wants to merge 5 commits into
flyteorg:mainfrom
davidlin20dev:feat/ray-submission-mode
Open

[V2][Ray] Make KubeRay submission mode configurable#7799
davidlin20dev wants to merge 5 commits into
flyteorg:mainfrom
davidlin20dev:feat/ray-submission-mode

Conversation

@davidlin20dev

@davidlin20dev davidlin20dev commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Adds a submissionMode setting to the Ray plugin configuration, letting platform operators choose how the KubeRay operator submits Ray jobs:

  • K8sJobMode (default): a submitter Kubernetes Job runs ray job submit against the RayCluster. This is the existing behavior and remains the default.
  • HTTPMode: the KubeRay operator submits the job via an HTTP request directly to the Ray head node. No submitter pod is created, so job failures caused by submitter pod eviction are eliminated.
  • SidecarMode: the KubeRay operator injects the submitter as a sidecar container in the Ray head pod. The submitter shares the head pod's fate, so it cannot be evicted independently of the job. Requires the head pod's restartPolicy to be Never, which Flyte already sets by default.
plugins:
  ray:
    submissionMode: HTTPMode

In HTTPMode and SidecarMode, the plugin skips building the submitter pod template, since no separate submitter pod exists. An invalid submissionMode value fails task construction with an explicit error rather than silently falling back.

Why are the changes needed?

In K8sJobMode, the submitter pod can be evicted independently of the Ray cluster (e.g., during node drains), causing KubeRay to mark an otherwise healthy job as failed. HTTPMode and SidecarMode both remove the standalone submitter pod from the picture. See #7772.

Per review discussion, the submission mode is a platform-level reliability concern, so it is exposed via plugin configuration (decided by the platform team) rather than per-task API. A per-task proto override can be added in the future if needed.

How was this patch tested?

  • Unit tests cover: explicit K8sJobMode, unset config (defaults to K8sJobMode), HTTPMode (asserts no submitter pod template is set), SidecarMode (asserts no submitter pod template is set), and an invalid value (asserts a hard error).
  • config_flags.go regenerated with the pflags generator.
  • Full flyteplugins/.../k8s/ray package test suite passes locally.

Labels

Related to #7772

Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
@davidlin20dev
davidlin20dev marked this pull request as draft August 6, 2026 17:21
@davidlin20dev
davidlin20dev marked this pull request as ready for review August 6, 2026 17:32
Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
Comment thread flyteidl2/plugins/ray.proto Outdated
option go_package = "github.com/flyteorg/flyte/v2/gen/go/flyteidl2/plugins";

// SubmissionMode specifies how the KubeRay operator submits the Ray job to the RayCluster.
enum SubmissionMode {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we just need to update the ray config here.

type Config struct {
// ShutdownAfterJobFinishes will determine whether to delete the ray cluster once rayJob succeed or failed
ShutdownAfterJobFinishes bool `json:"shutdownAfterJobFinishes,omitempty"`

The submission mode should be decided by the platform team

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pingsutw Thanks for the review! Just want to make sure I'm on the right track before I continue.

@popojk mentioned in Slack that users should be able to specify the mode, with both SDK and backend changes (which is what this PR implements), so I assumed we'd let users override the mode from the SDK. And what you mean is that only the platform team should pick the setting, is that correct?

So, should I do config-only, per-task only, or both (config default + per-task override, like ShutdownAfterJobFinishes)?

@pingsutw pingsutw Aug 6, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yup, ray plugin config is usually set by the platform team, so we only need to do config-only

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can add it to the proto in the future if someone really wants to override it per task

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I see, thanks for the clarification!

@pingsutw pingsutw added the flyte2 label Aug 7, 2026
@popojk

popojk commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

SidecarMode: The KubeRay operator injects a container into the Ray head Pod to submit the Ray job. This mode does not support clusterSelector, submitterPodTemplate, and submitterConfig, and requires the head Pod’s restart policy to be Never.

According to Kuberay doc, submitter also support sidecar mode, which means the ray operator will inject submitter into header node as sidecar. @pingsutw Do you think we should also support it as the config settings seems easy?

Per review feedback, the submission mode is a platform-level concern:
drop the SubmissionMode proto field and read the mode from the Ray
plugin config instead. Invalid config values fail task construction.

Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
@pingsutw

pingsutw commented Aug 7, 2026

Copy link
Copy Markdown
Member

yup, let's add that too

Per review discussion, also accept KubeRay's SidecarMode, which injects
the submitter as a container in the head pod. Flyte already defaults
Ray pod restartPolicy to Never, which SidecarMode requires.

Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
case string(rayv1.K8sJobMode), "":
// submissionMode already defaults to K8sJobMode
default:
return nil, fmt.Errorf("invalid ray submission mode %q: must be K8sJobMode, HTTPMode or SidecarMode", cfg.SubmissionMode)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could return flyteerr.Errorf(flyteerr.BadTaskSpecification, ), so the task won't be retried on this error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for the pointer! One question, I'm curious: I traced the code and understand flyteerr classifies the error with a code, but I couldn't find where that code prevents retries. It looks like plugin errors all go through recordSystemError and get retried regardless of code. Am I missing something?

Matches the file's existing error convention and prevents retries on a
deterministic configuration error.

Signed-off-by: davidlin20dev <davidlin20.dev@gmail.com>
@davidlin20dev
davidlin20dev force-pushed the feat/ray-submission-mode branch from 70b1206 to fb07f04 Compare August 8, 2026 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants