From d4298884499a486a170b765ad38551f7fd43da56 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 15 2020 07:54:35 +0000 Subject: [PATCH 1/3] Do not split the kerberos principal, it is needed to list the side-tags Signed-off-by: Pierre-Yves Chibon --- diff --git a/clean_up_side_tags.py b/clean_up_side_tags.py index 607ba4c..59d7afd 100644 --- a/clean_up_side_tags.py +++ b/clean_up_side_tags.py @@ -51,7 +51,7 @@ def main(args): # list side-tags: cmd = [ - conf["fedpkg"], "list-side-tags", "--user", conf["kb_principal"].rsplit('@', 1)[0] + conf["fedpkg"], "list-side-tags", "--user", conf["kb_principal"] ] output = run_command(cmd) From f8d2d2db729be9e3c3d8d4a6573da00c0169b278 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 15 2020 08:00:22 +0000 Subject: [PATCH 2/3] Clean up the side-tag in the runner rather than the test This way if an exception occurs before we get to the check if the tests passed or failed, we will still clean the side-tag. Signed-off-by: Pierre-Yves Chibon --- diff --git a/monitor_gating_multi_builds.py b/monitor_gating_multi_builds.py index c4b88ae..441b015 100644 --- a/monitor_gating_multi_builds.py +++ b/monitor_gating_multi_builds.py @@ -66,14 +66,15 @@ def get_arguments(args): return parser.parse_args(args) -def main(args): +def main(args, utils=None): """ Main method used by this script. """ start = datetime.datetime.utcnow() args = get_arguments(args) conf = toml.load(args.conf) - utils = MonitoringUtils() + if utils is None: + utils = MonitoringUtils() with tempfile.TemporaryDirectory(prefix="ci-test-") as folder: print(f"Working in {folder}\n") @@ -83,6 +84,9 @@ def main(args): nevrs, side_tag_name = utils.clone_and_bump( folder, nevrs, conf, conf["name_multi_1"], new_side_tag=True ) + # Store the side_tag_name so we can use it in the runner + utils.side_tag_name = side_tag_name + nevrs, _ = utils.clone_and_bump( folder, nevrs, conf, conf["name_multi_2"], target=side_tag_name ) @@ -218,15 +222,6 @@ def main(args): conf.get("koji_hub"), nevr, expected_ends=conf["koji_end_tag"], ) - try: - print(" Removing side-tag: %s" % side_tag_name) - cmd = [ - conf["fedpkg"], "remove-side-tag", side_tag_name - ] - output = run_command(cmd) - except Exception: - pass - utils.finalize(start) return utils.logs diff --git a/runner.py b/runner.py index 81ea2c3..f6032a0 100644 --- a/runner.py +++ b/runner.py @@ -18,7 +18,7 @@ import toml import monitor_gating_single_build import monitor_gating_multi_builds -from utils import run_command +from utils import MonitoringUtils, run_command s = sched.scheduler(time.time, time.sleep) conf = toml.load @@ -48,6 +48,17 @@ def notify(topic, message): print(f"Error sending fedora-messaging message: {err}") +def _clean_up_side_tags(utils): + try: + print(" Removing side-tag: %s" % utils.side_tag_name) + cmd = [ + conf["fedpkg"], "remove-side-tag", utils.side_tag_name + ] + output = run_command(cmd) + except Exception: + pass + + def schedule(conf): """ Run the test and schedules the next one. """ @@ -86,11 +97,16 @@ def schedule(conf): # Multi Build Gating multi_args = conf["workflow_multi_gating_args"].split() + utils = MonitoringUtils() notify( topic=f"multi-build.start", message={"arguments": multi_args, "runid": runid,}, ) - output = monitor_gating_multi_builds.main(multi_args) + try: + output = monitor_gating_multi_builds.main(multi_args, utils=utils) + finally: + _clean_up_side_tags(utils) + output_text = "\n".join(output) if "[FAILED]" not in output_text: result = "succeeded" From 06584432fc3d8c6386f750caaaba3a02bbda13ee Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Apr 15 2020 08:01:11 +0000 Subject: [PATCH 3/3] Send the a notification when the script itself crashed So we do not know if the test passed or failed, because an exception happened in the script. Signed-off-by: Pierre-Yves Chibon --- diff --git a/runner.py b/runner.py index f6032a0..f6211d0 100644 --- a/runner.py +++ b/runner.py @@ -127,6 +127,14 @@ def schedule(conf): print(f"Tests failed with: {err}", flush=True) print(sys.exc_info()[0]) + notify( + topic=f"multi-build.end.error", + message={ + "runid": runid, + "exception": err, + }, + ) + blocking_issues = utils.blocking_issues(blocker_tags) now = datetime.datetime.utcnow().strftime("%H:%M:%S") if blocking_issues: