Conversation
create_preset wraps everything in a BaseException handler that marks the session failed, and _resolve_preset_env ran inside that try. A resume from a shell missing a passthrough variable raises ConfigurationError before the agent is spawned, so the session is written failed, the workspace deleted, and load_resumable_session refuses it forever. Hoist env resolution above the session claim and the try: a pre-spawn failure leaves an interrupted session resumable, and a fresh attempt leaves no dead record behind. Fixes dstackai#4164
Contributor
|
@breken-ai we don't accept PRs if the implementation is not discussed first and the author that submits the PR is not actively using dstack. |
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.
Root cause
create_preset(src/dstack/_internal/cli/services/presets/create.py:444-446) wraps everything inexcept BaseException -> _close_agent_session(session, "failed"), and_resolve_preset_envran INSIDE the try. A resume from a shell missing a passthrough variable raises ConfigurationError before the agent is spawned and before anything changed - and the session is still written "failed", the workspace deleted, and load_resumable_session refuses it forever.Fix
Hoist
_resolve_preset_envabove the session claim and the try. The resume case stays "interrupted"/resumable; a fresh attempt leaves no dead record behind.Verification
Regression test resumes an interrupted session with a missing env var: on current HEAD the session flips to failed; with the fix it stays interrupted. Full create suite: 63 passed.
Fixes #4164