From 7a9eff7e653e2893a5f7c1e0fc055458ba6b8559 Mon Sep 17 00:00:00 2001 From: Bill Nottingham Date: Sat, 31 Oct 2020 23:10:22 -0400 Subject: [PATCH] Don't write a tower_version file in awx --- awx/asgi.py | 8 +++++--- awx/wsgi.py | 8 +++++--- installer/roles/image_build/templates/Dockerfile.j2 | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/awx/asgi.py b/awx/asgi.py index 698c5f7533..eb141aabdb 100644 --- a/awx/asgi.py +++ b/awx/asgi.py @@ -25,10 +25,12 @@ if MODE == 'production': try: fd = open("/var/lib/awx/.tower_version", "r") if fd.read().strip() != tower_version: - raise Exception() - except Exception: + raise ValueError() + except FileNotFoundError: + pass + except ValueError as e: logger.error("Missing or incorrect metadata for Tower version. Ensure Tower was installed using the setup playbook.") - raise Exception("Missing or incorrect metadata for Tower version. Ensure Tower was installed using the setup playbook.") + raise Exception("Missing or incorrect metadata for Tower version. Ensure Tower was installed using the setup playbook.") from e os.environ.setdefault("DJANGO_SETTINGS_MODULE", "awx.settings") diff --git a/awx/wsgi.py b/awx/wsgi.py index 2c60221e99..af8290cea3 100644 --- a/awx/wsgi.py +++ b/awx/wsgi.py @@ -29,10 +29,12 @@ if MODE == 'production': try: fd = open("/var/lib/awx/.tower_version", "r") if fd.read().strip() != tower_version: - raise Exception() - except Exception: + raise ValueError() + except FileNotFoundError: + pass + except ValueError as e: logger.error("Missing or incorrect metadata for Tower version. Ensure Tower was installed using the setup playbook.") - raise Exception("Missing or incorrect metadata for Tower version. Ensure Tower was installed using the setup playbook.") + raise Exception("Missing or incorrect metadata for Tower version. Ensure Tower was installed using the setup playbook.") from e # Return the default Django WSGI application. diff --git a/installer/roles/image_build/templates/Dockerfile.j2 b/installer/roles/image_build/templates/Dockerfile.j2 index 9ffc1c7c69..d47513e671 100644 --- a/installer/roles/image_build/templates/Dockerfile.j2 +++ b/installer/roles/image_build/templates/Dockerfile.j2 @@ -74,7 +74,7 @@ RUN cd /tmp && make requirements_awx_dev requirements_ansible_dev {% endif %} {% if not build_dev|bool %} COPY {{ awx_sdist_file }} /tmp/{{ awx_sdist_file }} -RUN mkdir -p -m 755 /var/lib/awx && echo "{{ awx_version }}" > /var/lib/awx/.tower_version && \ +RUN mkdir -p -m 755 /var/lib/awx && \ OFFICIAL=yes /var/lib/awx/venv/awx/bin/pip install /tmp/{{ awx_sdist_file }} {% endif %}