Fixed branch matching for parent jobs when on stable/1.0.0 branch

When a patch is submitted against a branch, Zuul CI will collect job
variants for each ci job and all its parent jobs. If both job.\
override-checkout and job.required-projects.override-checkout
attributes are not defined, then Zuul will for each (parent) job match
the current branch of the patch against all branches of the project in
which the job is defined. If no such branch exist in a project, then no
job variant matches and this job will be ignored [1].
For example, if a patch is submitted for our stable/1.0.0 branch, then
Zuul CI will try to match 'stable/1.0.0' against all branches in the
projects where job ansible-collections-openstack-functional-devstack
and its parent job openstacksdk-functional-devstack are defined. The
first is defined in openstack/ansible-collections-openstack/.zuul.yaml,
so a match for stable/1.0.0 will be found. But openstacksdk-functional-\
devstack is defined in openstack/openstacksdk/.zuul.yaml which has no
branch stable/1.0.0 defined. So Zuul will not schedule job ansible-\
collections-openstack-functional-devstack at all.

The solution is twofold. First, the base jobs such as ansible-\
collections-openstack-functional-devstack have to be changed to always
checkout existing branches in projects which define (parent) jobs.
Using job.override-checkout might have unintended sideeffects because
it will checkout the specified branch for all required projects which
also includes the project which the patch was submitted for. Instead
we set job.required-projects.override-checkout for all projects which
define parent jobs. For example, in ansible-collections-openstack-\
functional-devstack we set job.required-projects.override-checkout to
master for opendev.org/openstack/devstack which defines parent job
openstack-functional-devstack.

In child jobs which (re)define job.override-checkout, we have to change
job.required-projects.override-checkout for all projects which define
parent jobs to the value of job.override-checkout. If we fail to update
job.required-projects.override-checkout then Zuul will checkout the
branch which was defined in the base jobs because job.\
required-projects.override-checkout has higher precedence than job.\
override-checkout.

Setting attribute project.<pipeline>.debug to true helps with debugging
these job scheduling issues. "If this is set to true, Zuul will include
debugging information in reports it makes about items in the pipeline.
This should not normally be set, but in situations were it is difficult
to determine why Zuul did or did not run a certain job, the additional
information this provides may help" [2].

Note, once job scheduling has been completed, Zuul will use a different
algorithm to checkout projects which are listed in job.\
required-projects [3][4]. It will fallback to a default branch if no
matching branch can be found in projects [5].

Ref.:
[1] https://opendev.org/zuul/zuul/src/branch/master/zuul/model.py#L6996
[2] https://zuul-ci.org/docs/zuul/latest/config/project.html#attr-project.%3Cpipeline%3E.debug
[3] https://zuul-ci.org/docs/zuul/latest/job-content.html#git-repositories
[4] https://opendev.org/zuul/zuul/src/branch/master/zuul/executor/server.py#L1648
[5] https://zuul-ci.org/docs/zuul/latest/config/project.html#attr-project.default-branch

Change-Id: I31f9607ab7e2e2ae8534429da7f5e5f235560c56
This commit is contained in:
Jakob Meng 2022-03-24 12:00:32 +01:00
parent 771fb68f99
commit e2ee2d0f5d

View File

@ -11,6 +11,13 @@
required-projects:
- openstack/ansible-collections-openstack
- openstack/designate
# openstack/os-client-config is required through job openstacksdk-functional-devstack
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/devstack
override-checkout: master
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/openstacksdk
override-checkout: master
irrelevant-files: &ignore_files
- changelogs/.*
- galaxy.*
@ -146,7 +153,10 @@
using xena branch of openstacksdk and stable 2.12 branch of ansible
branches: stable/1.0.0
override-checkout: stable/xena
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: openstack/devstack
override-checkout: stable/xena
- name: openstack/openstacksdk
override-checkout: stable/xena
@ -158,7 +168,10 @@
using wallaby branch of openstacksdk and stable 2.12 branch of ansible
branches: stable/1.0.0
override-checkout: stable/wallaby
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: openstack/devstack
override-checkout: stable/wallaby
- name: openstack/openstacksdk
override-checkout: stable/wallaby
@ -170,7 +183,10 @@
using victoria branch of openstacksdk and stable 2.12 branch of ansible
branches: stable/1.0.0
override-checkout: stable/victoria
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: openstack/devstack
override-checkout: stable/victoria
- name: openstack/openstacksdk
override-checkout: stable/victoria
@ -182,10 +198,11 @@
using ussuri branch of openstacksdk and stable 2.11 branch of ansible
branches: stable/1.0.0
override-checkout: stable/ussuri
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: openstack/openstacksdk
- name: openstack/devstack
override-checkout: stable/ussuri
- name: openstack/os-client-config
- name: openstack/openstacksdk
override-checkout: stable/ussuri
- job:
@ -196,10 +213,11 @@
using train branch of openstacksdk and stable 2.11 branch of ansible
branches: stable/1.0.0
override-checkout: stable/train
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: openstack/openstacksdk
- name: openstack/devstack
override-checkout: stable/train
- name: openstack/os-client-config
- name: openstack/openstacksdk
override-checkout: stable/train
- job:
@ -210,7 +228,10 @@
using train branch of openstacksdk and stable 2.11 branch of ansible
branches: stable/1.0.0
override-checkout: stable/queens
# job.override-checkout will not override job.required-projects.override-checkout in parent jobs
required-projects:
- name: openstack/devstack
override-checkout: stable/queens
- name: openstack/openstacksdk
# Run queens with highest possible py2 version of SDK
override-checkout: stable/train
@ -264,12 +285,17 @@
parent: bifrost-integration-tinyipa-ubuntu-focal
required-projects:
- openstack/ansible-collections-openstack
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/bifrost
override-checkout: master
- job:
name: bifrost-keystone-collections-src
parent: bifrost-integration-tinyipa-keystone-ubuntu-focal
required-projects:
- openstack/ansible-collections-openstack
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/bifrost
override-checkout: master
# TripleO jobs
- job:
@ -279,6 +305,11 @@
featureset: '052'
consumer_job: false
build_container_images: true
required-projects:
- openstack/ansible-collections-openstack
- # always use master branch when collecting parent job variants, refer to git blame for rationale.
name: openstack/tripleo-ci
override-checkout: master
irrelevant-files: &irr_files
- .*molecule.*
- ^.*\.md$