fix: keep cwd at repo root through entire restart, revert try/except
The stack path in spec.yml is relative — both create_operation and up_operation need cwd at the repo root for stack_is_external() to resolve it. Move os.chdir(prev_cwd) to after up_operation completes instead of between the two operations. Reverts the SystemExit catch in call_stack_deploy_start — the root cause was cwd, not the hook. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>afd-dumpster-local-testing
parent
32f6e57b70
commit
61afeb255c
|
|
@ -414,8 +414,6 @@ def restart(ctx, stack_path, spec_file, config_file, force, expected_ip, image):
|
||||||
network_dir=None,
|
network_dir=None,
|
||||||
initial_peers=None,
|
initial_peers=None,
|
||||||
)
|
)
|
||||||
os.chdir(prev_cwd)
|
|
||||||
|
|
||||||
# Reload deployment context with updated spec
|
# Reload deployment context with updated spec
|
||||||
deployment_context.init(deployment_context.deployment_dir)
|
deployment_context.init(deployment_context.deployment_dir)
|
||||||
ctx.obj = deployment_context
|
ctx.obj = deployment_context
|
||||||
|
|
@ -443,6 +441,10 @@ def restart(ctx, stack_path, spec_file, config_file, force, expected_ip, image):
|
||||||
image_overrides=image_overrides or None,
|
image_overrides=image_overrides or None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Restore cwd after both create_operation and up_operation have run.
|
||||||
|
# Both need the relative stack path to resolve from repo_root.
|
||||||
|
os.chdir(prev_cwd)
|
||||||
|
|
||||||
print("\n=== Restart Complete ===")
|
print("\n=== Restart Complete ===")
|
||||||
print("Deployment updated via rolling update.")
|
print("Deployment updated via rolling update.")
|
||||||
if new_hostname and new_hostname != current_hostname:
|
if new_hostname and new_hostname != current_hostname:
|
||||||
|
|
|
||||||
|
|
@ -272,19 +272,7 @@ def call_stack_deploy_start(deployment_context):
|
||||||
create additional k8s resources (Services, etc.) in the deployment namespace.
|
create additional k8s resources (Services, etc.) in the deployment namespace.
|
||||||
The namespace can be derived as f"laconic-{deployment_context.id}".
|
The namespace can be derived as f"laconic-{deployment_context.id}".
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
python_file_paths = _commands_plugin_paths(deployment_context.stack.name)
|
python_file_paths = _commands_plugin_paths(deployment_context.stack.name)
|
||||||
except SystemExit:
|
|
||||||
# Stack path may not resolve from current cwd (e.g. during restart
|
|
||||||
# when cwd isn't the repo root). get_parsed_stack_config calls
|
|
||||||
# error_exit (sys.exit) when the stack directory doesn't exist.
|
|
||||||
# Most stacks don't have deploy hooks, so this is non-fatal.
|
|
||||||
if opts.o.debug:
|
|
||||||
print(
|
|
||||||
f"Could not resolve plugin paths for stack"
|
|
||||||
f" {deployment_context.stack.name}, skipping hooks"
|
|
||||||
)
|
|
||||||
return
|
|
||||||
for python_file_path in python_file_paths:
|
for python_file_path in python_file_paths:
|
||||||
if python_file_path.exists():
|
if python_file_path.exists():
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
spec = util.spec_from_file_location("commands", python_file_path)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue