From 92c2456851857c45e8de9a3ff8f167579e0588f4 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Wed, 10 Apr 2019 12:44:37 +0100 Subject: [PATCH] Write hash after compressing horizon static assets If you run the horizon container with a restart policy of never, and the static asset compression fails, the container fails to start, e.g. (seen in CI) ++ /usr/bin/manage.py collectstatic --noinput --clear Traceback (most recent call last): File "/usr/bin/manage.py", line 18, in from django.core.management import execute_from_command_line ImportError: No module named django.core.management However, with a restart policy of unless-stopped (the default). the horizon container will fail the first time but will succeed after a restart. This is because the settings bundle hash is updated before the compression is attempted. To fix this, update the hash after compression completes successfully. Change-Id: I3f1682ed55e7d45c1e97a1b34c7993aa839f0bb2 Closes-Bug: #1824137 --- docker/horizon/extend_start.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/horizon/extend_start.sh b/docker/horizon/extend_start.sh index 243841b53b..7006fafd55 100644 --- a/docker/horizon/extend_start.sh +++ b/docker/horizon/extend_start.sh @@ -3,6 +3,7 @@ set -o errexit FORCE_GENERATE="${FORCE_GENERATE}" +HASH_PATH=/var/lib/kolla/.settings.md5sum.txt # TODO(mgoddard): Remove this elif when Ubuntu has distro_python_version == 3. if [[ ${KOLLA_INSTALL_TYPE} == "binary" ]] && [[ "${KOLLA_BASE_DISTRO}" =~ ubuntu ]]; then @@ -299,11 +300,9 @@ function settings_bundle { function settings_changed { changed=1 - hash_path=/var/lib/kolla/.settings.md5sum.txt - if [[ ! -f $hash_path ]] || ! settings_bundle | md5sum -c --status $hash_path || [[ $FORCE_GENERATE == yes ]]; then + if [[ ! -f $HASH_PATH ]] || ! settings_bundle | md5sum -c --status $HASH_PATH || [[ $FORCE_GENERATE == yes ]]; then changed=0 - settings_bundle | md5sum > $hash_path fi return ${changed} @@ -349,6 +348,7 @@ fi if settings_changed; then ${MANAGE_PY} collectstatic --noinput --clear ${MANAGE_PY} compress --force + settings_bundle | md5sum > $HASH_PATH fi # NOTE(sbezverk) since Horizon is now storing logs in its own location, /var/log/horizon