Set up siblings dirs for each build in the loop

The buildx patch unfortunately changed the logic associated with
siblings to set up siblings in a loop one time, rather than to
do a loop of "set up siblings, build, cleanup siblings". This causes
builds to fail when they're using siblings with an error about
siblings dir not having been cleaned up.

Change-Id: I3c45bfa77ec9f2609689e04044c18f066adc9741
This commit is contained in:
Monty Taylor 2020-05-05 16:12:31 -05:00
parent 6f19965a6a
commit f449ae20fb
7 changed files with 36 additions and 8 deletions

View File

@ -50,5 +50,5 @@
- name: Cleanup sibling source directory - name: Cleanup sibling source directory
file: file:
path: '{{ zuul_work_dir }}/.zuul-siblings' path: '{{ zuul_work_dir }}/{{ zj_image.context }}/.zuul-siblings'
state: absent state: absent

View File

@ -1,3 +1,6 @@
- name: Set up siblings
include_tasks: siblings.yaml
- name: Build a docker image - name: Build a docker image
command: >- command: >-
docker build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }} docker build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }}
@ -23,3 +26,6 @@
--label "org.zuul-ci.change_url={{ zuul.change_url }}" --label "org.zuul-ci.change_url={{ zuul.change_url }}"
args: args:
chdir: "{{ zuul_work_dir }}/{{ zj_image.context }}" chdir: "{{ zuul_work_dir }}/{{ zj_image.context }}"
- name: Cleanup sibling source directory
include_tasks: clean-siblings.yaml

View File

@ -1,3 +1,6 @@
- name: Set up siblings
include_tasks: siblings.yaml
- name: Build a docker image - name: Build a docker image
command: >- command: >-
docker buildx build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }} docker buildx build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }}
@ -34,3 +37,6 @@
loop: "{{ zj_image.tags | default(['latest']) }}" loop: "{{ zj_image.tags | default(['latest']) }}"
loop_control: loop_control:
loop_var: zj_image_tag loop_var: zj_image_tag
- name: Cleanup sibling source directory
include_tasks: clean-siblings.yaml

View File

@ -0,0 +1,4 @@
- name: Cleanup sibling source directory
file:
path: '{{ zuul_work_dir }}/{{ zj_image.context }}/.zuul-siblings'
state: absent

View File

@ -14,12 +14,6 @@
- result_json_stat.stat.size > 0 - result_json_stat.stat.size > 0
- "'buildset_registry' in (lookup('file', zuul.executor.work_root + '/results.json') | from_json)" - "'buildset_registry' in (lookup('file', zuul.executor.work_root + '/results.json') | from_json)"
- name: Set up siblings
include_tasks: siblings.yaml
loop: "{{ docker_images }}"
loop_control:
loop_var: zj_image
# Docker doesn't understand docker push [1234:5678::]:5000/image/path:tag # Docker doesn't understand docker push [1234:5678::]:5000/image/path:tag
# so we set up /etc/hosts with a registry alias name to support ipv6 and 4. # so we set up /etc/hosts with a registry alias name to support ipv6 and 4.
- name: Configure /etc/hosts for buildset_registry to workaround docker not understanding ipv6 addresses - name: Configure /etc/hosts for buildset_registry to workaround docker not understanding ipv6 addresses

View File

@ -1,7 +1,10 @@
FROM docker.io/upstream/image FROM docker.io/upstream/image as first
ARG ZUUL_SIBLINGS="" ARG ZUUL_SIBLINGS=""
RUN echo "Zuul siblings: ${ZUUL_SIBLINGS}" RUN echo "Zuul siblings: ${ZUUL_SIBLINGS}"
RUN cp /test-nonce /test-nonce-is-there RUN cp /test-nonce /test-nonce-is-there
COPY .zuul-siblings/opendev.org/project/fake-sibling/file /target COPY .zuul-siblings/opendev.org/project/fake-sibling/file /target
COPY .zuul-siblings/openstack.org/project/fake-sibling/file /target COPY .zuul-siblings/openstack.org/project/fake-sibling/file /target
CMD echo "Zuul container test"; sleep infinity CMD echo "Zuul container test"; sleep infinity
FROM first as second
RUN echo "This is just to test that loops with siblings work"

View File

@ -140,9 +140,24 @@
siblings: siblings:
- opendev.org/project/fake-sibling - opendev.org/project/fake-sibling
- openstack.org/project/fake-sibling - openstack.org/project/fake-sibling
target: first
- context: test-playbooks/registry/docker-siblings
repository: downstream/image2
target: second
siblings:
- opendev.org/project/fake-sibling
- openstack.org/project/fake-sibling
_arch_docker_images: _arch_docker_images:
- context: test-playbooks/registry/docker-siblings - context: test-playbooks/registry/docker-siblings
repository: downstream/image repository: downstream/image
target: first
siblings:
- opendev.org/project/fake-sibling
- openstack.org/project/fake-sibling
arch: ['linux/amd64', 'linux/arm64']
- context: test-playbooks/registry/docker-siblings
repository: downstream/image2
target: second
siblings: siblings:
- opendev.org/project/fake-sibling - opendev.org/project/fake-sibling
- openstack.org/project/fake-sibling - openstack.org/project/fake-sibling