Better error logging for registry deployments. #754
@ -33,6 +33,7 @@ from stack_orchestrator.deploy.webapp.util import (LaconicRegistryClient,
|
||||
|
||||
|
||||
def process_app_deployment_request(
|
||||
run_id,
|
||||
ctx,
|
||||
laconic: LaconicRegistryClient,
|
||||
app_deployment_request,
|
||||
@ -281,17 +282,18 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
||||
for r in requests_to_execute:
|
||||
dump_known_requests(state_file, [r], "DEPLOYING")
|
||||
status = "ERROR"
|
||||
log_file = None
|
||||
run_log_file = None
|
||||
try:
|
||||
run_id = f"{r.id}-{str(time.time()).split('.')[0]}-{str(uuid.uuid4()).split('-')[0]}"
|
||||
if log_dir:
|
||||
log_dir = os.path.join(log_dir, r.id)
|
||||
if not os.path.exists(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
log_file_path = os.path.join(log_dir, f"{run_id}.log")
|
||||
print(f"Directing deployment logs to: {log_file_path}")
|
||||
log_file = open(log_file_path, "wt")
|
||||
run_log_dir = os.path.join(log_dir, r.id)
|
||||
if not os.path.exists(run_log_dir):
|
||||
os.mkdir(run_log_dir)
|
||||
run_log_file_path = os.path.join(run_log_dir, f"{run_id}.log")
|
||||
print(f"Directing deployment logs to: {run_log_file_path}")
|
||||
run_log_file = open(run_log_file_path, "wt")
|
||||
process_app_deployment_request(
|
||||
run_id,
|
||||
ctx,
|
||||
laconic,
|
||||
r,
|
||||
@ -301,12 +303,12 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
||||
os.path.abspath(deployment_parent_dir),
|
||||
kube_config,
|
||||
image_registry,
|
||||
log_file
|
||||
run_log_file
|
||||
)
|
||||
status = "DEPLOYED"
|
||||
except Exception as e:
|
||||
print("ERROR: " + str(e), file=log_file)
|
||||
print("ERROR: " + str(e), file=run_log_file)
|
||||
finally:
|
||||
dump_known_requests(state_file, [r], status)
|
||||
if log_file:
|
||||
log_file.close()
|
||||
if run_log_file:
|
||||
run_log_file.close()
|
||||
|
Loading…
Reference in New Issue
Block a user