✨ implement cluster sharing for KubeRayCluster
#251
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

This PR implements cluster sharing for
KubeRayCluster Dagster resource. Cluster sharing allows reusing the sameRayClustercreated by one of a previously executed Dagster steps across subsequent Dagster steps. It can dramatically speed up step setup, making if effectively instant in the presence of existing clusters.Because KubeRay doesn't currently provide a TTL mechanism for
RayCluster, this PR does 2 things:KubeRayCluster.cluster_sharing config is responsible for matching on existingRayCluster based on system (generated by Dagster anddagster-ray) and user-provided Kubernetes labelsKubeRayCluster placesdagster/lock-<run-id>-<step-key> annotations onRayCluster resources targeted by the current Dagster step. The annotation value is a serializedClusterSharingLock object with creation time and ttl set.dagster_ray.kuberay.cleanup_expired_rayclusters sensor monitorsRayClsuter resources and submits run requests for expired clusters usingdagster_ray.kuberay.delete_kuberay_rayclusters job.Resolve #131