Fix config dir processing for external stacks
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 51s
Deploy Test / Run deploy test suite (pull_request) Successful in 4m17s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m1s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 8m57s
Smoke Test / Run basic test suite (pull_request) Successful in 3m49s

This commit is contained in:
David Boreham 2024-04-23 10:30:49 -06:00
parent 6e4dae9777
commit 31581bbb53
2 changed files with 18 additions and 4 deletions

View File

@ -26,7 +26,8 @@ from stack_orchestrator import constants
from stack_orchestrator.opts import opts from stack_orchestrator.opts import opts
from stack_orchestrator.util import (get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, from stack_orchestrator.util import (get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config,
global_options, get_yaml, get_pod_list, get_pod_file_path, pod_has_scripts, global_options, get_yaml, get_pod_list, get_pod_file_path, pod_has_scripts,
get_pod_script_paths, get_plugin_code_paths, error_exit, env_var_map_from_file) get_pod_script_paths, get_plugin_code_paths, error_exit, env_var_map_from_file,
resolve_config_dir)
from stack_orchestrator.deploy.spec import Spec from stack_orchestrator.deploy.spec import Spec
from stack_orchestrator.deploy.deploy_types import LaconicStackSetupCommand from stack_orchestrator.deploy.deploy_types import LaconicStackSetupCommand
from stack_orchestrator.deploy.deployer_factory import getDeployerConfigGenerator from stack_orchestrator.deploy.deployer_factory import getDeployerConfigGenerator
@ -480,7 +481,6 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw
os.mkdir(destination_compose_dir) os.mkdir(destination_compose_dir)
destination_pods_dir = deployment_dir_path.joinpath("pods") destination_pods_dir = deployment_dir_path.joinpath("pods")
os.mkdir(destination_pods_dir) os.mkdir(destination_pods_dir)
data_dir = Path(__file__).absolute().parent.parent.joinpath("data")
yaml = get_yaml() yaml = get_yaml()
for pod in pods: for pod in pods:
pod_file_path = get_pod_file_path(stack_name, parsed_stack, pod) pod_file_path = get_pod_file_path(stack_name, parsed_stack, pod)
@ -497,7 +497,7 @@ def create_operation(deployment_command_context, spec_file, deployment_dir, netw
config_dirs = {pod} config_dirs = {pod}
config_dirs = config_dirs.union(extra_config_dirs) config_dirs = config_dirs.union(extra_config_dirs)
for config_dir in config_dirs: for config_dir in config_dirs:
source_config_dir = data_dir.joinpath("config", config_dir) source_config_dir = resolve_config_dir(stack_name, config_dir)
if os.path.exists(source_config_dir): if os.path.exists(source_config_dir):
destination_config_dir = deployment_dir_path.joinpath("config", config_dir) destination_config_dir = deployment_dir_path.joinpath("config", config_dir)
# If the same config dir appears in multiple pods, it may already have been copied # If the same config dir appears in multiple pods, it may already have been copied

View File

@ -94,6 +94,20 @@ def get_plugin_code_paths(stack) -> List[Path]:
return list(result) return list(result)
# # Find a config directory, looking first in any external stack
# and if not found there, internally
def resolve_config_dir(stack, config_dir_name: str):
if stack_is_external(stack):
# First try looking in the external stack for the compose file
config_base = Path(stack).parent.parent.joinpath("config")
proposed_dir = config_base.joinpath(config_dir_name)
if proposed_dir.exists():
return proposed_dir
# If we don't find it fall through to the internal case
config_base = get_internal_config_dir()
return config_base.joinpath(config_dir_name)
# Find a compose file, looking first in any external stack # Find a compose file, looking first in any external stack
# and if not found there, internally # and if not found there, internally
def resolve_compose_file(stack, pod_name: str): def resolve_compose_file(stack, pod_name: str):
@ -153,7 +167,7 @@ def get_internal_compose_file_dir():
return source_compose_dir return source_compose_dir
def get_config_file_dir(): def get_internal_config_dir():
# TODO: refactor to use common code with deploy command # TODO: refactor to use common code with deploy command
data_dir = Path(__file__).absolute().parent.joinpath("data") data_dir = Path(__file__).absolute().parent.joinpath("data")
source_config_dir = data_dir.joinpath("config") source_config_dir = data_dir.joinpath("config")