diff --git a/stack_orchestrator/deploy/deployment.py b/stack_orchestrator/deploy/deployment.py index 47606d5f..55a7598d 100644 --- a/stack_orchestrator/deploy/deployment.py +++ b/stack_orchestrator/deploy/deployment.py @@ -414,8 +414,6 @@ 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) 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, ) + # 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("Deployment updated via rolling update.") if new_hostname and new_hostname != current_hostname: diff --git a/stack_orchestrator/deploy/deployment_create.py b/stack_orchestrator/deploy/deployment_create.py index b03b12ca..725bf21f 100644 --- a/stack_orchestrator/deploy/deployment_create.py +++ b/stack_orchestrator/deploy/deployment_create.py @@ -272,19 +272,7 @@ def call_stack_deploy_start(deployment_context): create additional k8s resources (Services, etc.) in the deployment namespace. The namespace can be derived as f"laconic-{deployment_context.id}". """ - try: - 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 + python_file_paths = _commands_plugin_paths(deployment_context.stack.name) for python_file_path in python_file_paths: if python_file_path.exists(): spec = util.spec_from_file_location("commands", python_file_path)