From 29e37a31d77f55a2c0c9c29d9b5beca8bcf28cda Mon Sep 17 00:00:00 2001 From: Marc <980978+marchagen@users.noreply.github.com> Date: Wed, 15 Mar 2023 21:53:59 +0100 Subject: [PATCH 1/3] Catch DoesNotExist preventing startup Fixes failing startup because of python error: ``` Traceback (most recent call last): File "/opt/netbox/netbox/./manage.py", line 10, in execute_from_command_line(sys.argv) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line utility.execute() File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv self.execute(*args, **cmd_options) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute output = self.handle(*args, **options) File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/commands/shell.py", line 127, in handle exec(sys.stdin.read(), globals()) File "", line 2, in File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 650, in get raise self.model.DoesNotExist( users.models.Token.DoesNotExist: Token matching query does not exist. ``` --- docker/docker-entrypoint.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index c3fb321..9b39689 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -84,9 +84,12 @@ fi ./manage.py shell --interface python < Date: Thu, 16 Mar 2023 07:39:38 +0100 Subject: [PATCH 2/3] Preparation for 2.5.1 --- VERSION | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 437459c..73462a5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5.0 +2.5.1 diff --git a/docker-compose.yml b/docker-compose.yml index a4cc531..890cae6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '3.4' services: netbox: &netbox - image: docker.io/netboxcommunity/netbox:${VERSION-v3.4-2.5.0} + image: docker.io/netboxcommunity/netbox:${VERSION-v3.4-2.5.1} depends_on: - postgres - redis From b131b07af8a67399e966113e1bd2e9ad2568f36e Mon Sep 17 00:00:00 2001 From: Tobias Genannt Date: Thu, 16 Mar 2023 07:50:24 +0100 Subject: [PATCH 3/3] Simplified basse image check --- build-functions/get-public-image-config.sh | 5 ----- build.sh | 5 +++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/build-functions/get-public-image-config.sh b/build-functions/get-public-image-config.sh index 054efd2..70c292c 100644 --- a/build-functions/get-public-image-config.sh +++ b/build-functions/get-public-image-config.sh @@ -6,11 +6,6 @@ get_image_label() { skopeo inspect "docker://$image" | jq -r ".Labels[\"$label\"]" } -get_image_layers() { - local image=$1 - skopeo inspect "docker://$image" | jq -r ".Layers" -} - get_image_last_layer() { local image=$1 skopeo inspect "docker://$image" | jq -r ".Layers | last" diff --git a/build.sh b/build.sh index 6d79160..d1c08e4 100755 --- a/build.sh +++ b/build.sh @@ -324,11 +324,11 @@ else source ./build-functions/get-public-image-config.sh echo "Checking labels for '${FINAL_DOCKER_TAG}'" BASE_LAST_LAYER=$(get_image_last_layer "${DOCKER_FROM}") - mapfile -t IMAGES_LAYERS_OLD < <(get_image_layers "${FINAL_DOCKER_TAG}") + OLD_BASE_LAST_LAYER=$(get_image_label netbox.last-base-image-layer "${FINAL_DOCKER_TAG}") NETBOX_GIT_REF_OLD=$(get_image_label netbox.git-ref "${FINAL_DOCKER_TAG}") GIT_REF_OLD=$(get_image_label org.opencontainers.image.revision "${FINAL_DOCKER_TAG}") - if ! printf '%s\n' "${IMAGES_LAYERS_OLD[@]}" | grep -q -P "^${BASE_LAST_LAYER}\$"; then + if [ "${BASE_LAST_LAYER}" != "${OLD_BASE_LAST_LAYER}" ]; then SHOULD_BUILD="true" BUILD_REASON="${BUILD_REASON} ubuntu" fi @@ -388,6 +388,7 @@ fi if [ -n "${BUILD_REASON}" ]; then BUILD_REASON=$(sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' <<<"$BUILD_REASON") DOCKER_BUILD_ARGS+=(--label "netbox.build-reason=${BUILD_REASON}") + DOCKER_BUILD_ARGS+=(--label "netbox.last-base-image-layer=${BASE_LAST_LAYER}") fi # --build-arg