From 8ae55dd0b8e53e2afcc337204c469ca863823f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Kr=C4=8Dek?= Date: Mon, 5 Aug 2024 16:57:06 +0200 Subject: [PATCH] Refactor dev mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provides mechanism for future work to fix bug where when package file manifest changes, the changes were not reflected in to devmode-enabled container. It changes the strategy of installing projects in dev mode in containers. Instead of bind mounting the project's git repository to the venv of the container, the repository is bind mounted to /dev-mode/ from which the it is installed using pip on every startup of the container using kolla_install_projects script. Related-bug: #1814515 Change-Id: Ia1bdff87cba73587a03124ab78a56b21c6176373 Signed-off-by: Roman KrĨek --- docker/base/Dockerfile.j2 | 6 +++++- docker/base/install_projects.sh | 12 ++++++++++++ docker/base/start.sh | 3 +++ .../notes/bug-1814515-99197e13a6280861.yaml | 15 +++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 docker/base/install_projects.sh create mode 100644 releasenotes/notes/bug-1814515-99197e13a6280861.yaml diff --git a/docker/base/Dockerfile.j2 b/docker/base/Dockerfile.j2 index fe91ca6a6c..d220eba2c0 100644 --- a/docker/base/Dockerfile.j2 +++ b/docker/base/Dockerfile.j2 @@ -358,6 +358,7 @@ RUN sed -ri '/-session(\s+)optional(\s+)pam_systemd.so/d' /etc/pam.d/system-auth COPY set_configs.py /usr/local/bin/kolla_set_configs COPY start.sh /usr/local/bin/kolla_start COPY copy_cacerts.sh /usr/local/bin/kolla_copy_cacerts +COPY install_projects.sh /usr/local/bin/kolla_install_projects COPY httpd_setup.sh /usr/local/bin/kolla_httpd_setup COPY sudoers /etc/sudoers @@ -375,7 +376,10 @@ RUN chmod 755 /usr/local/bin/healthcheck_* {% endif %} RUN touch /usr/local/bin/kolla_extend_start \ - && chmod 755 /usr/local/bin/kolla_start /usr/local/bin/kolla_set_configs /usr/local/bin/kolla_copy_cacerts \ + && chmod 755 /usr/local/bin/kolla_start \ + /usr/local/bin/kolla_set_configs \ + /usr/local/bin/kolla_copy_cacerts \ + /usr/local/bin/kolla_install_projects \ && chmod 644 /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_httpd_setup \ && chmod 440 /etc/sudoers \ && mkdir -p /var/log/kolla \ diff --git a/docker/base/install_projects.sh b/docker/base/install_projects.sh new file mode 100644 index 0000000000..a9a7948d04 --- /dev/null +++ b/docker/base/install_projects.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# This script finds all projects in /dev-mode folder and +# installs them using pip +# The projects are mounted there when dev mode is enabled for them +# in kolla-ansible + +if [ -d "/dev-mode" ]; then + for project in /dev-mode/*; do + pip install -U "$project" + done +fi diff --git a/docker/base/start.sh b/docker/base/start.sh index 79d7f7c747..2b77b4ea26 100644 --- a/docker/base/start.sh +++ b/docker/base/start.sh @@ -15,6 +15,9 @@ ARGS="" # Install/remove custom CA certificates sudo kolla_copy_cacerts +# Install projects that are in /dev-mode +kolla_install_projects + if [[ ! "${!KOLLA_SKIP_EXTEND_START[@]}" ]]; then # Run additional commands if present . kolla_extend_start diff --git a/releasenotes/notes/bug-1814515-99197e13a6280861.yaml b/releasenotes/notes/bug-1814515-99197e13a6280861.yaml new file mode 100644 index 0000000000..640a46343c --- /dev/null +++ b/releasenotes/notes/bug-1814515-99197e13a6280861.yaml @@ -0,0 +1,15 @@ +--- +fixes: + - | + Provides mechanism for future work to fix bug where when package file + manifest changes, the changes were not reflected in to devmode-enabled + container. + `LP#1814515 `__ + +upgrade: + - | + Changes the strategy of installing projects in dev mode in containers. + Instead of bind mounting the project's git repository to the venv + of the container, the repository is bind mounted to + /dev-mode/ from which the project is installed using pip + on every startup of the container using kolla_install_projects script.