<#7460 feat: add ClusterPlugin interface for share...
# flyte-github
a
#7460 feat: add ClusterPlugin interface for shared-cluster plugins Pull request opened by pingsutw Tracking issue Related to shared-cluster execution for Ray (and future cluster-backed plugins). Why are the changes needed? Some plugins want to run a job on top of a shared, long-lived cluster instead of an ephemeral per-task resource: the cluster is created once (keyed by a deterministic name, e.g. the hash of the job-spec proto), reused by every task whose spec maps to the same name, and the job is created only after the cluster is ready. The existing
Plugin
interface (single
BuildResource
) cannot express this two-resource lifecycle. This PR adds the generic
ClusterPlugin
interface and registry plumbing, plus a few supporting changes that let a shared-cluster consumer reuse the in-tree Ray plugin's job-shaping and link handling. Concrete consumers live downstream and drive
ClusterPlugin
with their own evaluation loop. What changes were proposed in this pull request? 1. New
ClusterPlugin
interface (
flyteplugins/.../pluginmachinery/k8s/plugin.go
)
Sits alongside the existing
Plugin
interface. Instead of one
BuildResource
, it declares two resources, a readiness check, and cluster cleanup: type ClusterPlugin interface { GetClusterName(ctx, taskCtx) (string, error) // deterministic name = hash(spec proto) BuildClusterResource(ctx, taskCtx) (client.Object, error) // the shared cluster BuildClusterIdentityResource(ctx, taskMeta) (client.Object, error) IsClusterReady(ctx, pluginContext, cluster) (bool, error) BuildJobResource(ctx, taskCtx, clusterName) (client.Object, error) // job bound to the cluster BuildJobIdentityResource(ctx, taskMeta) (client.Object, error) GetJobPhase(ctx, pluginContext, job) (pluginsCore.PhaseInfo, error) GetProperties() PluginProperties StartCleanup(ctx, kubeClient) // GC idle clusters; called once at load } The cluster resource is intentionally not owned by any task execution (no owner reference, no finalizer), so completing or aborting one task never deletes a cluster other tasks may still be using; the job resource is owned normally. Because cluster resources outlive individual tasks, cleanup is the plugin's own responsibility:
StartCleanup
is called once at load time so a plugin can start a background loop that deletes clusters once they have been idle past their TTL. 2. Registry validation (
pluginmachinery/registry.go
)
PluginEntry
gains
ClusterPlugin
+ `ClusterResourceToWatch`;
RegisterK8sPlugin
validates exactly one of `Plugin`/`ClusterPlugin` is set. 3. Executor guard (
executor/pkg/plugin/registry.go
)
The executor's plugin registry skips ClusterPlugin-only entries (it has no manager for them) instead of wrapping a nil
Plugin
. 4. Ray plugin: submitter-pod labels + reusable link-readiness helper (
plugins/k8s/ray/ray.go
)
• Submitter-pod execution metadata.
buildSubmitterPodTemplate
now sources the submitter pod's labels/annotations from the task execution metadata, the same way the head and worker pod templates already do. KubeRay uses
SubmitterPodTemplate
verbatim, so previously the submitter pod carried none of the task's execution labels — leaving it invisible to anything that locates a task's pods by execution metadata (e.g. log tailing). •
UpdateLinkReadiness
exported.
The dashboard/IDE task-link readiness handling inside
GetTaskPhase
is extracted into an exported helper, so a wrapper that determines head readiness through a different lookup (e.g. a job submitted to a pre-existing cluster via
ClusterSelector
) can reuse the identical link handling instead of duplicating it. 5.
LogContext.pod_name_prefix
→ repeated
pod_name_prefixes
(
flyteidl2/core/execution.proto
,
logs/dataplane/payload.proto
)
A task's pods can live under more than one name prefix — e.g. a job on a shared cluster has its own submitter pod plus the cluster's head/worker pods, which are named differently. The scalar
pod_name_prefix
can only describe one, so it is marked
[deprecated = true]
(still populated with the task's own prefix for readers that predate the new field) and a repeated
pod_name_prefixes
is added: element 0 is the task's own prefix; later elements cover pods living outside it. Additive and wire-compatible — existing readers keep using the scalar. How was this patch tested? •
registry_test.go
covers registration/validation of ClusterPlugin entries. •
go test ./flyteplugins/...
and
./executor/...
pass. • Branch is merged with current
main
. flyteorg/flyte