From a3ccf6fb01993a2061fb5be0b188eb58c83ce83f Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 9 Jul 2020 09:49:39 -0400 Subject: [PATCH] Relax filter_images_with_labels() and re-add kolla_version This patch does 2 things (on purpose for easier backport without CI failures): 1) TCIB: add "kolla_version" for backward compatibility In TripleO CI, we run container updates using tripleo-modify-image role but only for the images with "kolla_version" label. https://opendev.org/openstack/tripleo-quickstart-extras/src/branch/master/roles/undercloud-deploy/templates/containers-prepare-parameter.yaml.j2#L13 In the future, we'll rename this LABEL to be more TCIB specific and remove "kolla" from it, but for now let's have it for backward compatibility. 2) image_uploader: relax logic for filter_images_with_labels() modify_only_with_labels is a list of labels that can be set to find out what images we want to modify with the tripleo-modify-image role. Before, all the items in the list must be present in the image Labels; which is too strict (e.g. kolla_version label used by quickstart doesn't exist in the new images with TCIB). Let's relax it so we will modify the image if at least one label is present in there. Related-Bug: #1886914 Change-Id: Ia9b75f8a50c83fc38d7a4f6d5e6a9726d82fbd8c (cherry picked from commit af74c389e4d73041c2a052e633f8e3f7efaa550d) --- container-images/tcib/base/base.yaml | 1 + tripleo_common/image/image_uploader.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/container-images/tcib/base/base.yaml b/container-images/tcib/base/base.yaml index e69bd6193..74e27e6fb 100644 --- a/container-images/tcib/base/base.yaml +++ b/container-images/tcib/base/base.yaml @@ -37,6 +37,7 @@ tcib_envs: tcib_gather_files: '{{ lookup(''fileglob'', ''/usr/share/tripleo-common/container-images/kolla/base/*'', wantlist=True) }}' tcib_labels: maintainer: OpenStack TripleO team + kolla_version: none tcib_packages: common: - ca-certificates diff --git a/tripleo_common/image/image_uploader.py b/tripleo_common/image/image_uploader.py index 482058f5a..8d73a5a32 100644 --- a/tripleo_common/image/image_uploader.py +++ b/tripleo_common/image/image_uploader.py @@ -1036,8 +1036,15 @@ class BaseImageUploader(object): raise image_labels = self._image_labels( url, session=session) - if set(labels).issubset(set(image_labels)): - images_with_labels.append(image) + # The logic is the following: if one of the labels in + # modify_only_with_labels parameter is present in the image, it + # will match and add the images that need to be modified. + for label in labels: + if label in image_labels: + # we found a matching label, adding the image + # and leave the loop. + images_with_labels.append(image) + break return images_with_labels