Skip to content

fix: resolve preset env before claiming the agent session - #4278

Closed
breken-ai wants to merge 1 commit into
dstackai:masterfrom
breken-ai:fix-4164-presolve-env-before-session-claim
Closed

breken-ai wants to merge 1 commit into
dstackai:masterfrom
breken-ai:fix-4164-presolve-env-before-session-claim

Conversation

@breken-ai

Copy link
Copy Markdown

Root cause

create_preset (src/dstack/_internal/cli/services/presets/create.py:444-446) wraps everything in except BaseException -> _close_agent_session(session, "failed"), and _resolve_preset_env ran 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_env above 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

Built by breken, your AI support engineer - breken.ai - this one's on us.

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
@peterschmidt85

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: [Presets] Any failure during resume marks the creation permanently failed

2 participants