Repository navigation
Add orphan cleanup for cloud resources - #4401
Merged
Merged
Conversation
Placeholder instances carry the provider_ref of run_job() instead of jobs, and ProviderRefModel keeps refs after owners are deleted, so superseded job submissions no longer need to wait for orphan cleanup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #3453
dstackcould leave cloud resources running ifdstackor provider bug.Solution:
provider_refthat backends set on the resources they create, and every issuedprovider_refis recorded in a newprovider_refstable. Records outlive deleted instances, such as job placeholder instances deleted after a failedrun_job(), so their leftover resources are still recognized.ComputeWithResourceListingSupportmixin, which lists resources marked withprovider_refand deletes them.provider_refs, andOrphanCleanupPipelineperiodically lists those of active projects, matches resources to instances byprovider_ref, and reports or deletes orphans, emitting events.DSTACK_SERVER_ORPHAN_CLEANUP_MODEisreportby default (log, Sentry and events only), withdeleteandoffas alternatives.contributing/ORPHAN-CLEANUP.mdfor the design.Limitations:
dstackbackend lists the shared base backend accounts, so listings repeat per project. The plan is to clean up each shared account once and match resources across projects.provider_refsare never deleted yet. The plan is to delete rows of deleted or terminated instances after a retention period.deleteshould become the default only after runningreportin production and adding a circuit breaker that stops deletion when unexpectedly many orphans are found.