Use a DummyFrozenJob in build cleanup

There is a place where we try to clean up builds that we may no
longer have FrozenJobs for; but the cleanup methods expect FrozenJob
objects essentially just to get the job name.

To make it more clear that's what's happening, use a dedicated object
to pass that information.

Change-Id: Ieb85bcba6d9a184e28120953adf882e4720621b2
This commit is contained in:
James E. Blair 2024-01-11 13:49:44 -08:00 committed by Simon Westphahl
parent dc49013bb6
commit 7eb3fbeb97
No known key found for this signature in database
1 changed files with 10 additions and 3 deletions

View File

@ -2,7 +2,7 @@
# Copyright 2013 OpenStack Foundation
# Copyright 2013 Antoine "hashar" Musso
# Copyright 2013 Wikimedia Foundation Inc.
# Copyright 2021-2022 Acme Gating, LLC
# Copyright 2021-2024 Acme Gating, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -66,7 +66,6 @@ from zuul.model import (
EnqueueEvent,
FilesChangesCompletedEvent,
HoldRequest,
Job,
MergeCompletedEvent,
NodesProvisionedEvent,
PromoteEvent,
@ -172,6 +171,12 @@ class SchedulerStatsElection(SessionAwareElection):
super().__init__(client.client, self.election_root)
class DummyFrozenJob:
"""Some internal methods expect a FrozenJob for cleanup;
use this when we don't actually have one"""
pass
class Scheduler(threading.Thread):
"""The engine of Zuul.
@ -2878,8 +2883,10 @@ class Scheduler(threading.Thread):
# allows reporting the build via SQL and cleaning up build
# resources.
build = Build()
job = Job(event.job_name)
job = DummyFrozenJob()
job.name = event.job_name
job.uuid = event.job_uuid
job.provides = []
# MODEL_API < 25
job._job_id = job.uuid or job.name
build._set(