diff options
| author | Michal Nasiadka <mnasiadka@gmail.com> | 2026-11-15 19:05:38 -0600 |
|---|---|---|
| committer | Michal Nasiadka <mnasiadka@gmail.com> | 2026-11-22 08:43:12 +0000 |
| commit | 542febbb12c619ee25cbb94b31fff6f916bcff33 (patch) | |
| tree | 4fccd98b7117803db5a6078e25f5b3cc27826760 /kolla/docker | |
| parent | e0bca6ad209b206ed0626574d102e8ab25a54cd9 (diff) | |
| download | kolla-542febbb12c619ee25cbb94b31fff6f916bcff33.tar.gz kolla-542febbb12c619ee25cbb94b31fff6f916bcff33.zip | |
base: Install full systemd on Debian and Ubuntu
Rocky images already ship full systemd, as lvm2 and
iscsi-initiator-utils in base hard-require it.
Debian and Ubuntu base install systemd-standalone-sysusers instead,
to keep systemd out because the OpenSearch packages call systemctl
in their postinst without checking whether systemd is running.
grafana, nova-compute and nova-libvirt pull in full systemd as a hard
dependency anyway, replacing systemd-standalone-sysusers in those images.
Install full systemd in base on Debian and Ubuntu, so that all
distributions behave the same, and while installing OpenSearch and
OpenSearch Dashboards replace systemctl and systemd-tmpfiles with
/bin/true using new disable_systemd_commands and
restore_systemd_commands macros.
Remove /etc/machine-id in base, as installing systemd creates it and
it would otherwise be shared by all containers.
Disable the Bifrost OCI artifact registry in bifrost-base, as
kolla-ansible already does. It runs podman as a systemd service,
which doesn't work inside a container, and installing it pulled
podman, buildah and systemd into the image.
Related-Bug: #2138705
Change-Id: I2e362eb89501c1dfc1daa42f764ef2b21046749c
Signed-off-by: Michal Nasiadka <mnasiadka@gmail.com>
Diffstat (limited to 'kolla/docker')
| -rw-r--r-- | kolla/docker/base/Dockerfile.j2 | 10 | ||||
| -rw-r--r-- | kolla/docker/bifrost/bifrost-base/build_arg.yml | 3 | ||||
| -rw-r--r-- | kolla/docker/macros.j2 | 18 | ||||
| -rw-r--r-- | kolla/docker/opensearch/opensearch-dashboards/Dockerfile.j2 | 8 | ||||
| -rw-r--r-- | kolla/docker/opensearch/opensearch/Dockerfile.j2 | 8 |
5 files changed, 45 insertions, 2 deletions
diff --git a/kolla/docker/base/Dockerfile.j2 b/kolla/docker/base/Dockerfile.j2 index c0f52b230..731aaaf60 100644 --- a/kolla/docker/base/Dockerfile.j2 +++ b/kolla/docker/base/Dockerfile.j2 @@ -150,7 +150,10 @@ RUN {{ macros.install_packages(base_rocky_yum_repo_packages | customizable("rock # Install base packages {{ macros.enable_extra_repos(['epel']) }} -{{ macros.install_packages(base_rocky_packages | customizable("rocky_packages")) }} +{# NOTE(mnasiadka): systemd (pulled in by lvm2 and iscsi-initiator-utils) creates + /etc/machine-id, which must not be shared by all containers. #} +{{ macros.install_packages(base_rocky_packages | customizable("rocky_packages")) }} \ + && rm -f /etc/machine-id {# endif for base_package_type rpm #} {% elif base_package_type == 'deb' %} @@ -228,7 +231,6 @@ COPY apt_preferences /etc/apt/preferences.d/kolla-custom {% set base_apt_packages = [ 'apt-utils', 'dumb-init', - 'systemd-standalone-sysusers', 'gawk', 'iproute2', 'kmod', @@ -248,6 +250,7 @@ COPY apt_preferences /etc/apt/preferences.d/kolla-custom 'python3-yaml', 'socat', 'sudo', + 'systemd', 'tgt', 'uuid-runtime', 'patch' @@ -294,6 +297,9 @@ RUN apt-get --error-on=any update \ && apt-get -y upgrade \ && apt-get -y dist-upgrade \ && {{ macros.install_packages(base_apt_packages | customizable('apt_packages'), True) }} \ + {#- NOTE(mnasiadka): systemd creates /etc/machine-id, which must not be + shared by all containers. #} + && rm -f /etc/machine-id \ # NOTE: python3-pip installs dependent tzdata package and blocks mount in docker - 2091161 && unlink /etc/localtime diff --git a/kolla/docker/bifrost/bifrost-base/build_arg.yml b/kolla/docker/bifrost/bifrost-base/build_arg.yml index 8c810f133..02c3359fd 100644 --- a/kolla/docker/bifrost/bifrost-base/build_arg.yml +++ b/kolla/docker/bifrost/bifrost-base/build_arg.yml @@ -5,3 +5,6 @@ install_dib: true create_image_via_dib: false ansible_python_interpreter: /var/lib/kolla/venv/bin/python internal_ip: "127.0.0.1" +# Bifrost's OCI artifact registry runs podman as a systemd service, which +# doesn't work inside a container; kolla-ansible disables it too. +enable_registry: false diff --git a/kolla/docker/macros.j2 b/kolla/docker/macros.j2 index 6d43b4ccf..f44cad572 100644 --- a/kolla/docker/macros.j2 +++ b/kolla/docker/macros.j2 @@ -68,6 +68,24 @@ RUN usermod --append --home {{ homedir }} --groups kolla {{ name }} \ {%- endif %} {%- endmacro %} +{# NOTE(mnasiadka): Some Debian/Ubuntu packages call systemctl or + systemd-tmpfiles from their maintainer scripts without checking that + systemd is running, which fails during an image build. Replace them with + /bin/true while installing such packages, and restore them afterwards. #} +{% macro disable_systemd_commands() -%} +{% for cmd in ['/usr/bin/systemctl', '/usr/bin/systemd-tmpfiles'] -%} + dpkg-divert --local --rename --add {{ cmd }} && ln -s /bin/true {{ cmd }} + {%- if not loop.last %} && {% endif %} +{%- endfor %} +{%- endmacro %} + +{% macro restore_systemd_commands() -%} +{% for cmd in ['/usr/bin/systemctl', '/usr/bin/systemd-tmpfiles'] -%} + rm -f {{ cmd }} && dpkg-divert --local --rename --remove {{ cmd }} + {%- if not loop.last %} && {% endif %} +{%- endfor %} +{%- endmacro %} + {% macro enable_extra_repos(repos) %} {{ handle_repos(repos, 'enable') }} diff --git a/kolla/docker/opensearch/opensearch-dashboards/Dockerfile.j2 b/kolla/docker/opensearch/opensearch-dashboards/Dockerfile.j2 index f6bd31587..3d145930a 100644 --- a/kolla/docker/opensearch/opensearch-dashboards/Dockerfile.j2 +++ b/kolla/docker/opensearch/opensearch-dashboards/Dockerfile.j2 @@ -14,7 +14,15 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" {% set opensearch_dashboards_packages = ['opensearch-dashboards'] %} +{% if base_package_type == 'deb' %} +{# NOTE(mnasiadka): The opensearch-dashboards postinst runs systemctl and + systemd-tmpfiles without checking whether systemd is running. #} +RUN {{ macros.disable_systemd_commands() }} \ + && {{ macros.install_packages(opensearch_dashboards_packages | customizable("packages"), chain=True) }} \ + && {{ macros.restore_systemd_commands() }} \ +{% else %} {{ macros.install_packages(opensearch_dashboards_packages | customizable("packages")) }} \ +{% endif %} && chown -R opensearch-dashboards:opensearch-dashboards /usr/share/opensearch-dashboards COPY extend_start.sh /usr/local/bin/kolla_extend_start diff --git a/kolla/docker/opensearch/opensearch/Dockerfile.j2 b/kolla/docker/opensearch/opensearch/Dockerfile.j2 index 2765d9985..fca2efff5 100644 --- a/kolla/docker/opensearch/opensearch/Dockerfile.j2 +++ b/kolla/docker/opensearch/opensearch/Dockerfile.j2 @@ -18,7 +18,15 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" ENV OPENSEARCH_INITIAL_ADMIN_PASSWORD="Kolla24OpenSearch" +{% if base_package_type == 'deb' %} +{# NOTE(mnasiadka): The opensearch postinst runs systemctl and + systemd-tmpfiles without checking whether systemd is running. #} +RUN {{ macros.disable_systemd_commands() }} \ + && {{ macros.install_packages(opensearch_packages | customizable("packages"), chain=True) }} \ + && {{ macros.restore_systemd_commands() }} \ +{% else %} {{ macros.install_packages(opensearch_packages | customizable("packages")) }} \ +{% endif %} && chown -R opensearch:opensearch /usr/share/opensearch \ && rm -f /etc/opensearch/*.pem \ && rm -f /etc/opensearch/securityadmin_demo.sh |
