aboutsummaryrefslogtreecommitdiff
path: root/kolla/image
diff options
context:
space:
mode:
authorMarcin Juszkiewicz <marcin.juszkiewicz@linaro.org>2020-09-21 12:27:34 +0000
committerMarcin Juszkiewicz <marcin.juszkiewicz@linaro.org>2020-09-21 12:31:07 +0000
commite40bf80f98ec470f4358fe9511d3bea968f2a25f (patch)
tree2b80f857bf9f4df770719513e50013aa0d32fc1e /kolla/image
parent87730f8f7c02e5d295ccde2925c8b7b14e4ef693 (diff)
downloadkolla-e40bf80f98ec470f4358fe9511d3bea968f2a25f.tar.gz
kolla-e40bf80f98ec470f4358fe9511d3bea968f2a25f.zip
Create 'infra' type of images
If image is always built same way then it is considered 'infra'. BINARY_SOURCE_IMAGES variable lists toplevel binary/source images. There is a switch "--infra-rename" to enable renaming of infrastructure images. Disabled by default to keep compatibility (will be enabled in future patch). Implements: blueprint infra-images Change-Id: Ib5235e3576ef0eae3efab9559ef44227c928067c
Diffstat (limited to 'kolla/image')
-rwxr-xr-xkolla/image/build.py43
1 files changed, 41 insertions, 2 deletions
diff --git a/kolla/image/build.py b/kolla/image/build.py
index 5a2f4104b..4af4e4437 100755
--- a/kolla/image/build.py
+++ b/kolla/image/build.py
@@ -192,6 +192,13 @@ UNBUILDABLE_IMAGES = {
},
}
+# NOTE(hrw): all non-infra images and their children
+BINARY_SOURCE_IMAGES = [
+ 'kolla-toolbox',
+ 'openstack-base',
+ 'monasca-thresh',
+]
+
class ArchivingError(Exception):
pass
@@ -751,7 +758,10 @@ class KollaWorker(object):
sys.exit(1)
self.image_prefix = self.base + '-' + self.install_type + '-'
- self.infra_image_prefix = self.image_prefix
+ if self.conf.infra_rename:
+ self.infra_image_prefix = self.base + '-infra-'
+ else:
+ self.infra_image_prefix = self.image_prefix
self.regex = conf.regex
self.image_statuses_bad = dict()
@@ -1004,6 +1014,15 @@ class KollaWorker(object):
if not self.conf.work_dir:
shutil.rmtree(self.temp_dir)
+ def change_install_type(self, image, old_type, new_type):
+ # NOTE(hrw): /self.base to make sure that we do not break image name
+ image.canonical_name = image.canonical_name.replace(
+ f'/{self.base}-{old_type}-',
+ f'/{self.base}-{new_type}-')
+ if image.children:
+ for tmp_image in image.children:
+ tmp_image.parent_name = image.canonical_name
+
def filter_images(self):
"""Filter which images to build."""
filter_ = list()
@@ -1085,6 +1104,25 @@ class KollaWorker(object):
if image.status != STATUS_UNBUILDABLE:
image.status = STATUS_MATCHED
+ if self.conf.infra_rename:
+ for image in self.images:
+ is_infra = True
+ if image.name in BINARY_SOURCE_IMAGES:
+ # keep as is
+ is_infra = False
+ else:
+ # let's check ancestors if any of them is binary/source
+ ancestor_image = image
+ while (ancestor_image.parent is not None):
+ ancestor_image = ancestor_image.parent
+ if ancestor_image.name in BINARY_SOURCE_IMAGES:
+ is_infra = False
+ break
+
+ if is_infra:
+ self.change_install_type(image, self.install_type, 'infra')
+ pass
+
# Next, mark any skipped images.
for image in self.images:
if image.status != STATUS_MATCHED:
@@ -1343,7 +1381,8 @@ class KollaWorker(object):
for parent_name, parent in sort_images.items():
for image in sort_images.values():
- if image.parent_name == parent_name:
+ if (image.parent_name == parent_name or image.parent_name ==
+ parent_name.replace(self.install_type, 'infra')):
parent.children.append(image)
image.parent = parent