ci_run_n_monitor: add RUNNING_STATUSES and use it where appropriate

A couple of these were trivially missing the `created` status which
usually doesn't stay for long enough for this very slow script to notice.

The `cancel_job()` function will no longer cancel manual jobs waiting to
be started.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29917>
This commit is contained in:
Eric Engestrom
2024-06-26 18:00:43 +02:00
committed by Marge Bot
parent a578101d5b
commit 0b09cf63a8

View File

@@ -60,6 +60,7 @@ STATUS_COLORS = {
} }
COMPLETED_STATUSES = {"success", "failed"} COMPLETED_STATUSES = {"success", "failed"}
RUNNING_STATUSES = {"created", "pending", "running"}
def print_job_status(job, new_status=False) -> None: def print_job_status(job, new_status=False) -> None:
@@ -190,13 +191,13 @@ def monitor_pipeline(
if ( if (
{"failed"}.intersection(target_statuses.values()) {"failed"}.intersection(target_statuses.values())
and not {"running", "pending"}.intersection(target_statuses.values()) and not RUNNING_STATUSES.intersection(target_statuses.values())
): ):
return None, 1, execution_times return None, 1, execution_times
if ( if (
{"skipped"}.intersection(target_statuses.values()) {"skipped"}.intersection(target_statuses.values())
and not {"running", "pending"}.intersection(target_statuses.values()) and not RUNNING_STATUSES.intersection(target_statuses.values())
): ):
print( print(
Fore.RED, Fore.RED,
@@ -231,7 +232,7 @@ def enable_job(
if ( if (
(job.status in COMPLETED_STATUSES and action_type != "retry") (job.status in COMPLETED_STATUSES and action_type != "retry")
or (job.status == "manual" and not force_manual) or (job.status == "manual" and not force_manual)
or job.status in {"skipped", "running", "created", "pending"} or job.status in {"skipped"} | RUNNING_STATUSES
): ):
return job return job
@@ -258,13 +259,7 @@ def enable_job(
def cancel_job(project, job) -> None: def cancel_job(project, job) -> None:
"""Cancel GitLab job""" """Cancel GitLab job"""
if job.status in [ if job.status not in RUNNING_STATUSES:
"canceled",
"canceling",
"success",
"failed",
"skipped",
]:
return return
pjob = project.jobs.get(job.id, lazy=True) pjob = project.jobs.get(job.id, lazy=True)
pjob.cancel() pjob.cancel()