ci_run_n_monitor: update job when it goes through enable_job()

`enable_job()` modifies the job, so we need to make sure we get the
updated job back out of it.

The next two commits take care of the two specific code paths.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27499>
This commit is contained in:
Eric Engestrom
2024-02-05 22:59:51 +00:00
committed by Marge Bot
parent 5758a5d660
commit bce1230587

View File

@@ -120,10 +120,10 @@ def monitor_pipeline(
stress < 0
or sum(stress_status_counter[job.name].values()) < stress
):
enable_job(project, job, "retry", force_manual)
job = enable_job(project, pipeline, job, "retry", force_manual)
stress_status_counter[job.name][job.status] += 1
else:
enable_job(project, job, "target", force_manual)
job = enable_job(project, pipeline, job, "target", force_manual)
print_job_status(job, job.status not in target_statuses[job.name])
target_statuses[job.name] = job.status
@@ -136,7 +136,7 @@ def monitor_pipeline(
# run dependencies and cancel the rest
if job.name in dependencies:
enable_job(project, job, "dep", True)
job = enable_job(project, pipeline, job, "dep", True)
if job.status == "failed":
deps_failed.append(job.name)
else:
@@ -193,17 +193,18 @@ def monitor_pipeline(
def enable_job(
project: gitlab.v4.objects.Project,
pipeline: gitlab.v4.objects.ProjectPipeline,
job: gitlab.v4.objects.ProjectPipelineJob,
action_type: Literal["target", "dep", "retry"],
force_manual: bool,
) -> None:
) -> gitlab.v4.objects.ProjectPipelineJob:
"""enable job"""
if (
(job.status in ["success", "failed"] and action_type != "retry")
or (job.status == "manual" and not force_manual)
or job.status in ["skipped", "running", "created", "pending"]
):
return
return job
pjob = project.jobs.get(job.id, lazy=True)
@@ -221,6 +222,8 @@ def enable_job(
print(Fore.MAGENTA + f"{jtype} job {job.name} manually enabled" + Style.RESET_ALL)
return job
def cancel_job(project, job) -> None:
"""Cancel GitLab job"""