From ca5fffaed57757b655cc6ce97439cc9ff8f9274c Mon Sep 17 00:00:00 2001 From: David Boreham Date: Thu, 4 Jul 2024 19:46:42 +0000 Subject: [PATCH] Add logging to webapp deployer (#863) Helps with diagnosing failures and odd behavior seen in the deployer in production. Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/863 Co-authored-by: David Boreham Co-committed-by: David Boreham --- .../deploy/webapp/deploy_webapp_from_registry.py | 13 +++++++++---- stack_orchestrator/deploy/webapp/util.py | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index 7c21b2a8..130670b8 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -122,21 +122,26 @@ def process_app_deployment_request( shared_tag_exists = remote_image_exists(image_registry, app_image_shared_tag) if shared_tag_exists and not force_rebuild: # simply add our unique tag to the existing image and we are done - logger.log(f"Using existing app image {app_image_shared_tag} for {deployment_container_tag}") + logger.log( + f"Existing image found for this app: {app_image_shared_tag} " + "tagging it with: {deployment_container_tag} to use in this deployment" + ) add_tags_to_image(image_registry, app_image_shared_tag, deployment_container_tag) logger.log("Tag complete") else: extra_build_args = [] # TODO: pull from request - logger.log(f"Building container image {deployment_container_tag}") + logger.log(f"Building container image: {deployment_container_tag}") build_container_image(app, deployment_container_tag, extra_build_args, logger) logger.log("Build complete") - logger.log(f"Pushing container image {deployment_container_tag}") + logger.log(f"Pushing container image: {deployment_container_tag}") push_container_image(deployment_dir, logger) logger.log("Push complete") # The build/push commands above will use the unique deployment tag, so now we need to add the shared tag. - logger.log(f"Updating app image tag {app_image_shared_tag} from build of {deployment_container_tag}") + logger.log(f"Adding global app image tag: {app_image_shared_tag} to newly built image: {deployment_container_tag}") add_tags_to_image(image_registry, deployment_container_tag, app_image_shared_tag) logger.log("Tag complete") + else: + logger.log("Requested app is already deployed, skipping build and image push") # 7. update config (if needed) if not deployment_record or file_hash(deployment_config_file) != deployment_record.attributes.meta.config: diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index 5c484ed1..8179f4cd 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -299,11 +299,12 @@ def push_container_image(deployment_dir, logger): def deploy_to_k8s(deploy_record, deployment_dir, logger): if not deploy_record: - command = "up" + command = "start" else: command = "update" logger.log("Deploying to k8s ...") + logger.log(f"Running {command} command on deployment dir: {deployment_dir}") result = subprocess.run([sys.argv[0], "deployment", "--dir", deployment_dir, command], stdout=logger.file, stderr=logger.file) result.check_returncode()