Handle no metadata in zuul artifact items

When pulling from intermediate registries we check zuul for artifacts of
a certain type. Unfortunately we do so blindly without checking that the
metadata field exists for the artifact. These leads to errors like:

  "msg": "The conditional check 'item.metadata.type | default('') == 'container_image'' failed.
  The error was: error while evaluating conditional (item.metadata.type | default('') == 'container_image'): 'dict object' has no attribute 'metadata'

  http://logs.openstack.org/12/643712/1/gate/opendev-buildset-registry/1016e6e/job-output.txt.gz#_2019-03-18_19_28_39_060210

Address this by checking the metadata field prior to accessing it.

Change-Id: I02bbeddccdda836fc313eccce09e4cb0beb6262a
This commit is contained in:
Clark Boylan 2019-03-18 14:20:55 -07:00
parent 05d6187825
commit d2aaa5529c
1 changed files with 1 additions and 1 deletions

View File

@ -63,7 +63,7 @@
skopeo --insecure-policy copy
{{ item.url }}
docker://{{ buildset_registry.host }}:{{ buildset_registry.port }}/{{ item.metadata.repository }}:{{ item.metadata.tag }}
when: "item.metadata.type | default('') == 'container_image'"
when: "metadata in item and item.metadata.type | default('') == 'container_image'"
loop: "{{ zuul.artifacts | default([]) }}"
always:
- name: Remove docker user config