fix: chdir to repo root before create_operation in restart

The spec's "stack:" value is a relative path that must resolve from
the repo root. stack_is_external() checks Path(stack).exists() from
cwd, which fails when cwd isn't the repo root.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
A. F. Dudley 2026-03-20 15:06:38 +00:00
parent 2484abfcce
commit 0ac886bf95

View File

@ -397,7 +397,14 @@ def restart(ctx, stack_path, spec_file, config_file, force, expected_ip, image):
print("\n[2/4] Hostname unchanged, skipping DNS verification")
# Step 3: Sync deployment directory with spec
# The spec's "stack:" value is often a relative path (e.g.
# "stack-orchestrator/stacks/dumpster") that must resolve from the
# repo root. Change cwd so stack_is_external() sees it correctly.
print("\n[3/4] Syncing deployment directory...")
import os
prev_cwd = os.getcwd()
os.chdir(repo_root)
deploy_ctx = make_deploy_context(ctx)
create_operation(
deployment_command_context=deploy_ctx,
@ -407,6 +414,7 @@ def restart(ctx, stack_path, spec_file, config_file, force, expected_ip, image):
network_dir=None,
initial_peers=None,
)
os.chdir(prev_cwd)
# Reload deployment context with updated spec
deployment_context.init(deployment_context.deployment_dir)