From 0b61ef94b4c4db7c1aa764c10157f773bf0fdacd Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 09 2020 11:17:59 +0000 Subject: Port the monitoring script to the new messages from the CI pipeline Signed-off-by: Pierre-Yves Chibon --- diff --git a/monitor_gating.py b/monitor_gating.py index e89c7c7..b34527a 100644 --- a/monitor_gating.py +++ b/monitor_gating.py @@ -161,7 +161,7 @@ def main(): lookup_results_datagrepper( base_url=conf["datagrepper"], name="CI", - topic=f"org.centos.{conf['_ci_env']}.ci.pipeline.allpackages-pr.package.running", + topic=f"org.centos.{conf['_ci_env']}.ci.koji-build.test.running", rev=f"PR-{pr_id}", ) # Check that CI flag pending was set @@ -178,7 +178,7 @@ def main(): lookup_results_datagrepper( base_url=conf["datagrepper"], name="CI", - topic=f"org.centos.{conf['_ci_env']}.ci.pipeline.allpackages-pr.complete", + topic=f"org.centos.{conf['_ci_env']}.ci.koji-build.test.complete", rev=f"PR-{pr_id}", ) # Check that CI flag failure was set @@ -246,14 +246,14 @@ def main(): lookup_results_datagrepper( base_url=conf["datagrepper"], name="CI (running)", - topic=f"org.centos.{conf['_ci_env']}.ci.pipeline.allpackages-build.package.running", + topic=f"org.centos.{conf['_ci_env']}.ci.koji-build.test.running", nevr=nevr, ) # Check at the CI pipeline has completed lookup_results_datagrepper( base_url=conf["datagrepper"], name="CI (complete)", - topic=f"org.centos.{conf['_ci_env']}.ci.pipeline.allpackages-build.complete", + topic=f"org.centos.{conf['_ci_env']}.ci.koji-build.test.error", nevr=nevr, duration=30, ) diff --git a/utils.py b/utils.py index 7f48570..c21a4c7 100644 --- a/utils.py +++ b/utils.py @@ -353,7 +353,7 @@ def lookup_results_datagrepper( f"&start={start_time.timestamp()}&row_per_page=10" ) - success = False + success = None returned_status = None info_log = None nevrs = nevrs or [] @@ -366,6 +366,8 @@ def lookup_results_datagrepper( end_url += f"&page={page}" data = requests.get(end_url).json() for message in data["raw_messages"]: + + # Old message format from the CI pipeline if "ci.pipeline" in message["topic"] and ( message["msg"]["nvr"] == nevr or message["msg"]["nvr"] in nevrs @@ -374,6 +376,24 @@ def lookup_results_datagrepper( success = True returned_status = message["msg"]["status"] break + + # New message format from the CI pipeline + if ( + "ci.koji-build" in message["topic"] and + message["msg"]["artifact"]["nvr"] == nevr + ): + if message["topic"].endswith("test.complete"): + success = True + returned_status = message["msg"]["test"]["result"] + elif message["topic"].endswith("test.error"): + success = True + returned_status = "error" + elif message["topic"].endswith("test.running"): + success = True + returned_status = "running" + break + + # resultsdb messages if ( "resultsdb" in message["topic"] and "nvr" in message["msg"]["data"] @@ -383,6 +403,8 @@ def lookup_results_datagrepper( success = True returned_status = message["msg"]["outcome"] break + + # greenwave messages if ( "greenwave" in message["topic"] and ( @@ -394,6 +416,8 @@ def lookup_results_datagrepper( success = True returned_status = message["msg"]["policies_satisfied"] break + + # waiverdb messages if ( "waiverdb" in message["topic"] and ( @@ -405,9 +429,9 @@ def lookup_results_datagrepper( success = True returned_status = "" break - if success: + if success is not None: break - if success: + if success is not None: break if (datetime.datetime.utcnow() - start).seconds > (duration * 60):