Fix child job skip with paused deduplicated parent

When a build pauses, it can also return a list of child jobs to execute.
If the paused build was deduplicated we need to call `setResult()` on
all items that have that particular build.

Change-Id: Iead5c02032bccf46852ee6b2c8adf714689aa2f5
This commit is contained in:
Simon Westphahl 2023-09-22 12:28:45 +02:00
parent a06d4110f5
commit 1da1c5e014
No known key found for this signature in database
2 changed files with 35 additions and 1 deletions

View File

@ -2507,6 +2507,39 @@ class TestGerritCircularDependencies(ZuulTestCase):
], ordered=False)
self._assert_job_deduplication_check()
@simple_layout('layouts/job-dedup-child-jobs.yaml')
def test_job_deduplication_check_child_jobs_paused_parent(self):
# Test that child jobs returned from deduplicated paused
# parents are deduplicated and correctly skipped.
# child1-job should not run, but child2 should run and be
# deduplicated. This uses auto deduplication.
self.executor_server.returnData(
'common-job', 'refs/changes/02/2/1',
{'zuul': {
'child_jobs': ['child2-job'],
'pause': True,
}}
)
self.executor_server.returnData(
'common-job', 'refs/changes/01/1/1',
{'zuul': {
'child_jobs': ['child2-job'],
'pause': True,
}}
)
self._test_job_deduplication_check()
self.assertHistory([
dict(name="common-job", result="SUCCESS", changes="2,1 1,1"),
dict(name="project1-job", result="SUCCESS", changes="2,1 1,1"),
dict(name="project2-job", result="SUCCESS", changes="1,1 2,1"),
dict(name="child2-job", result="SUCCESS", changes="2,1 1,1"),
# This is deduplicated
# dict(name="common-job", result="SUCCESS", changes="2,1 1,1"),
# dict(name="child2-job", result="SUCCESS", changes="2,1 1,1"),
], ordered=False)
self._assert_job_deduplication_check()
@simple_layout('layouts/job-dedup-mismatched-child-jobs.yaml')
def test_job_deduplication_check_mismatched_child_jobs(self):
# Test that a parent job with different child jobs is

View File

@ -1899,7 +1899,8 @@ class PipelineManager(metaclass=ABCMeta):
log = get_annotated_logger(self.log, build.zuul_event_id)
item = build.build_set.item
log.debug("Build %s of %s paused", build, item.change)
item.setResult(build)
for item_with_build in self._getItemsWithBuild(build):
item_with_build.setResult(build)
# We need to resume builds because we could either have no children
# or have children that are already skipped.