From 0bb6a65ed6b64fa15fd8f89434ec6862c7300974 Mon Sep 17 00:00:00 2001 From: Seunghun Lee Date: Thu, 3 Apr 2025 14:51:04 +0100 Subject: [PATCH] [2024.1 only] Extend base_tag check to cover more ubuntu base image tags https://hub.docker.com provides base Ubuntu images with two type of namings. For example for Ubuntu Noble, there are ``24.04``, ``noble`` and ``noble-20250127``. Currently whenever Kolla checks base tag to determine which Ubuntu release is being used, it only expects tag of version number. So if users use base tag with release codename, they will not get correct python version or other dependencies. Fixing this by extending all base_tag checks to include case for release codenames. Change-Id: Iab02de97cdde79db540c7336512d7014f9b71753 --- docker/base/Dockerfile.j2 | 8 ++++---- docker/bifrost/bifrost-base/Dockerfile.j2 | 2 +- docker/cinder/cinder-base/Dockerfile.j2 | 2 +- kolla/image/kolla_worker.py | 2 +- kolla/template/methods.py | 9 ++++++++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/docker/base/Dockerfile.j2 b/docker/base/Dockerfile.j2 index ea33be3000..57ee7be1d6 100644 --- a/docker/base/Dockerfile.j2 +++ b/docker/base/Dockerfile.j2 @@ -241,15 +241,15 @@ RUN cat /tmp/kolla_bashrc >> /etc/bash.bashrc \ RUN rm -f /etc/apt/sources.list.d/debian.sources COPY sources.list.{{ base_distro }} /etc/apt/sources.list {% elif ( base_distro == 'ubuntu' and base_arch == 'x86_64' ) %} -{% if base_distro_tag.startswith('22.04') %} +{% if base_distro_tag.startswith('22.04') or base_distro_tag.startswith('jammy') %} COPY sources.list.{{ base_distro }}.jammy /etc/apt/sources.list -{% elif base_distro_tag.startswith('24.04') %} +{% elif base_distro_tag.startswith('24.04') or base_distro_tag.startswith('noble') %} COPY sources.list.{{ base_distro }}.noble /etc/apt/sources.list {% endif %} {% else %} -{% if base_distro_tag.startswith('22.04') %} +{% if base_distro_tag.startswith('22.04') or base_distro_tag.startswith('jammy')%} COPY sources.list.{{ base_distro }}.jammy.{{ base_arch }} /etc/apt/sources.list -{% elif base_distro_tag.startswith('24.04') %} +{% elif base_distro_tag.startswith('24.04') or base_distro_tag.startswith('noble')%} COPY sources.list.{{ base_distro }}.noble.{{ base_arch }} /etc/apt/sources.list {% endif %} {% endif %} diff --git a/docker/bifrost/bifrost-base/Dockerfile.j2 b/docker/bifrost/bifrost-base/Dockerfile.j2 index b6267b670d..3eb21d04f2 100644 --- a/docker/bifrost/bifrost-base/Dockerfile.j2 +++ b/docker/bifrost/bifrost-base/Dockerfile.j2 @@ -37,7 +37,7 @@ ENV ANSIBLE_GATHER_TIMEOUT=30 {% block bifrost_ansible_install %} {%- if base_package_type == 'deb' %} RUN apt-get --error-on=any update && \ - {%- if base_distro_tag.startswith('24.04') %} + {%- if base_distro_tag.startswith('24.04') or base_distro_tag.startswith('noble') %} bash -c 'export VENV=/var/lib/kolla/venv && \ {# NOTE(darmach): Bumped to ansible-core 2.16 to match Python 3.12 #} $VENV/bin/pip install "ansible>=9,<10" && \ diff --git a/docker/cinder/cinder-base/Dockerfile.j2 b/docker/cinder/cinder-base/Dockerfile.j2 index 5b73abfb10..ae8597a187 100644 --- a/docker/cinder/cinder-base/Dockerfile.j2 +++ b/docker/cinder/cinder-base/Dockerfile.j2 @@ -32,7 +32,7 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build ] %} {% endif %} -{% if base_distro_tag.startswith('24.04') %} +{% if base_distro_tag.startswith('24.04') or base_distro_tag.startswith('noble') %} RUN {{ macros.upper_constraints_version_change("taskflow", "5.6.0", "5.8.0") }} {% endif %} diff --git a/kolla/image/kolla_worker.py b/kolla/image/kolla_worker.py index fe245fd090..7097899b78 100644 --- a/kolla/image/kolla_worker.py +++ b/kolla/image/kolla_worker.py @@ -122,7 +122,7 @@ def __init__(self, conf): self.distro_package_manager = 'apt' self.base_package_type = 'deb' elif self.base in ['ubuntu']: - if self.base_tag.startswith('24.04'): + if self.base_tag.startswith(('24.04', 'noble')): self.conf.distro_python_version = "3.12" else: self.conf.distro_python_version = "3.10" diff --git a/kolla/template/methods.py b/kolla/template/methods.py index f190845b68..4ab876f03c 100644 --- a/kolla/template/methods.py +++ b/kolla/template/methods.py @@ -96,7 +96,14 @@ def handle_repos(context, reponames, mode): repofile = context.get('repos_yaml') or ( os.path.dirname(os.path.realpath(__file__)) + - ('/repos-noble.yaml' if base_distro_tag == '24.04' else '/repos.yaml') + ( + '/repos-noble.yaml' + if ( + base_distro_tag and + base_distro_tag.startswith(('24.04', 'noble')) + ) + else '/repos.yaml' + ) ) with open(repofile, 'r') as repos_file: