Better error logging
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 39s
Deploy Test / Run deploy test suite (pull_request) Successful in 4m22s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m45s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 6m32s
Smoke Test / Run basic test suite (pull_request) Successful in 6m7s
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 39s
Deploy Test / Run deploy test suite (pull_request) Successful in 4m22s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m45s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 6m32s
Smoke Test / Run basic test suite (pull_request) Successful in 6m7s
This commit is contained in:
parent
5985242b8c
commit
08ec8d1eaa
@ -42,18 +42,8 @@ def process_app_deployment_request(
|
|||||||
deployment_parent_dir,
|
deployment_parent_dir,
|
||||||
kube_config,
|
kube_config,
|
||||||
image_registry,
|
image_registry,
|
||||||
log_parent_dir
|
|
||||||
):
|
|
||||||
run_id = f"{app_deployment_request.id}-{str(time.time()).split('.')[0]}-{str(uuid.uuid4()).split('-')[0]}"
|
|
||||||
log_file=None
|
log_file=None
|
||||||
if log_parent_dir:
|
):
|
||||||
log_dir = os.path.join(log_parent_dir, app_deployment_request.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 build logs to: {log_file_path}")
|
|
||||||
log_file = open(log_file_path, "wt")
|
|
||||||
|
|
||||||
# 1. look up application
|
# 1. look up application
|
||||||
app = laconic.get_record(app_deployment_request.attributes.application, require=True)
|
app = laconic.get_record(app_deployment_request.attributes.application, require=True)
|
||||||
|
|
||||||
@ -291,7 +281,16 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
|||||||
for r in requests_to_execute:
|
for r in requests_to_execute:
|
||||||
dump_known_requests(state_file, [r], "DEPLOYING")
|
dump_known_requests(state_file, [r], "DEPLOYING")
|
||||||
status = "ERROR"
|
status = "ERROR"
|
||||||
|
log_file = None
|
||||||
try:
|
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")
|
||||||
process_app_deployment_request(
|
process_app_deployment_request(
|
||||||
ctx,
|
ctx,
|
||||||
laconic,
|
laconic,
|
||||||
@ -302,8 +301,12 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
|
|||||||
os.path.abspath(deployment_parent_dir),
|
os.path.abspath(deployment_parent_dir),
|
||||||
kube_config,
|
kube_config,
|
||||||
image_registry,
|
image_registry,
|
||||||
log_dir
|
log_file
|
||||||
)
|
)
|
||||||
status = "DEPLOYED"
|
status = "DEPLOYED"
|
||||||
|
except Exception as e:
|
||||||
|
print("ERROR: " + str(e), file=log_file)
|
||||||
finally:
|
finally:
|
||||||
dump_known_requests(state_file, [r], status)
|
dump_known_requests(state_file, [r], status)
|
||||||
|
if log_file:
|
||||||
|
log_file.close()
|
||||||
|
@ -227,8 +227,16 @@ def build_container_image(app_record, tag, extra_build_args=[], log_file=None):
|
|||||||
git_env = dict(os.environ.copy())
|
git_env = dict(os.environ.copy())
|
||||||
# Never prompt
|
# Never prompt
|
||||||
git_env["GIT_TERMINAL_PROMPT"] = "0"
|
git_env["GIT_TERMINAL_PROMPT"] = "0"
|
||||||
|
try:
|
||||||
subprocess.check_call(["git", "clone", repo, clone_dir], env=git_env, stdout=log_file, stderr=log_file)
|
subprocess.check_call(["git", "clone", repo, clone_dir], env=git_env, stdout=log_file, stderr=log_file)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"git clone failed. Is the repository {repo} private?", file=log_file)
|
||||||
|
raise e
|
||||||
|
try:
|
||||||
subprocess.check_call(["git", "checkout", ref], cwd=clone_dir, env=git_env, stdout=log_file, stderr=log_file)
|
subprocess.check_call(["git", "checkout", ref], cwd=clone_dir, env=git_env, stdout=log_file, stderr=log_file)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"git checkout failed. Does ref {ref} exist?", file=log_file)
|
||||||
|
raise e
|
||||||
else:
|
else:
|
||||||
result = subprocess.run(["git", "clone", "--depth", "1", repo, clone_dir], stdout=log_file, stderr=log_file)
|
result = subprocess.run(["git", "clone", "--depth", "1", repo, clone_dir], stdout=log_file, stderr=log_file)
|
||||||
result.check_returncode()
|
result.check_returncode()
|
||||||
|
Loading…
Reference in New Issue
Block a user