From 8430c83e89f0e8514403d086b7c95ec0061a33ba Mon Sep 17 00:00:00 2001 From: David Boreham Date: Thu, 4 Jul 2024 15:40:06 -0600 Subject: [PATCH] Derive the webapp host container id from stable data --- .../deploy/webapp/deploy_webapp_from_registry.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index 130670b8..edb353d9 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -99,16 +99,19 @@ def process_app_deployment_request( deployment_record = laconic.get_record(app_deployment_crn) deployment_dir = os.path.join(deployment_parent_dir, fqdn) + # At present we use this to generate a unique but stable ID for the app's host container + # TODO: implement support to derive this transparently from the already-unique deployment id + unique_deployment_id = hashlib.md5(fqdn.encode()).hexdigest()[:16] deployment_config_file = os.path.join(deployment_dir, "config.env") # TODO: Is there any reason not to simplify the hash input to the app_deployment_crn? - deployment_container_tag = "laconic-webapp/%s:local" % hashlib.md5(deployment_dir.encode()).hexdigest() + deployment_container_tag = "laconic-webapp/%s:local" % unique_deployment_id app_image_shared_tag = f"laconic-webapp/{app.id}:local" # b. check for deployment directory (create if necessary) if not os.path.exists(deployment_dir): if deployment_record: raise Exception("Deployment record %s exists, but not deployment dir %s. Please remove name." % (app_deployment_crn, deployment_dir)) - print("deploy_webapp", deployment_dir) + logger.log(f"Creating webapp deployment in: {deployment_dir} with container id: {deployment_container_tag}") deploy_webapp.create_deployment(ctx, deployment_dir, deployment_container_tag, f"https://{fqdn}", kube_config, image_registry, env_filename) elif env_filename: