From 83196b5f6f8c4c2bbdb6a5e635eff34935f2d509 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Thu, 2 Aug 2018 16:05:31 -0400 Subject: [PATCH] Write timestamps when important events happen during the compose (#409). Right now, this is when the compose is queued up, when it is started by anaconda, and when it is finished (whether that's success or not). (cherry picked from commit 3ba9d53b8b0c00a2a5b1ce36788522d9083b2057) --- src/pylorax/api/compose.py | 2 ++ src/pylorax/api/queue.py | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pylorax/api/compose.py b/src/pylorax/api/compose.py index 56155cd2..321a8b55 100644 --- a/src/pylorax/api/compose.py +++ b/src/pylorax/api/compose.py @@ -49,6 +49,7 @@ from pykickstart.version import makeVersion from pylorax.api.projects import projects_depsolve, projects_depsolve_with_size, dep_nevra from pylorax.api.projects import ProjectsError from pylorax.api.recipes import read_recipe_and_id +from pylorax.api.timestamp import write_timestamp from pylorax.imgutils import default_image_name from pylorax.sysutils import joinpaths @@ -378,6 +379,7 @@ def start_build(cfg, dnflock, gitlock, branch, recipe_name, compose_type, test_m if test_mode > 0: open(joinpaths(results_dir, "TEST"), "w").write("%s" % test_mode) + write_timestamp(results_dir, "created") log.info("Adding %s (%s %s) to compose queue", build_id, recipe["name"], compose_type) os.symlink(results_dir, joinpaths(lib_dir, "queue/new/", build_id)) diff --git a/src/pylorax/api/queue.py b/src/pylorax/api/queue.py index e116de38..78d49652 100644 --- a/src/pylorax/api/queue.py +++ b/src/pylorax/api/queue.py @@ -31,7 +31,7 @@ import time from pylorax import find_templates from pylorax.api.compose import move_compose_results from pylorax.api.recipes import recipe_from_file -from pylorax.api.timestamp import timestamp_dict +from pylorax.api.timestamp import write_timestamp, timestamp_dict from pylorax.base import DataHolder from pylorax.creator import run_creator from pylorax.sysutils import joinpaths @@ -108,6 +108,7 @@ def monitor(cfg): make_compose(cfg, os.path.realpath(dst)) log.info("Finished building %s, results are in %s", dst, os.path.realpath(dst)) open(joinpaths(dst, "STATUS"), "w").write("FINISHED\n") + write_timestamp(dst, "finished") except Exception: import traceback log.error("traceback: %s", traceback.format_exc()) @@ -115,6 +116,7 @@ def monitor(cfg): # TODO - Write the error message to an ERROR-LOG file to include with the status # log.error("Error running compose: %s", e) open(joinpaths(dst, "STATUS"), "w").write("FAILED\n") + write_timestamp(dst, "finished") os.unlink(dst) @@ -195,6 +197,7 @@ def make_compose(cfg, results_dir): log.debug("cfg = %s", install_cfg) try: test_path = joinpaths(results_dir, "TEST") + write_timestamp(results_dir, "started") if os.path.exists(test_path): # Pretend to run the compose time.sleep(5)