From 8b730884d70e7e2712bc79ad14c79b5fc0cc746d Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 4 Jul 2023 22:46:03 +1000 Subject: [PATCH] Handle exception when creating default labels (#5163) * Handle exception when creating default labels - Running workers in parallel may cause race conditions - Catch any exception which is raised * Prevent password from being logged * Update default timeout for docker --- InvenTree/InvenTree/apps.py | 4 ++-- InvenTree/label/apps.py | 22 ++++++++++++---------- docker/production/.env | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/InvenTree/InvenTree/apps.py b/InvenTree/InvenTree/apps.py index 8a286a5982..2c553149b0 100644 --- a/InvenTree/InvenTree/apps.py +++ b/InvenTree/InvenTree/apps.py @@ -195,8 +195,8 @@ class InvenTreeConfig(AppConfig): else: new_user = user.objects.create_superuser(add_user, add_email, add_password) logger.info(f'User {str(new_user)} was created!') - except IntegrityError as _e: - logger.warning(f'The user "{add_user}" could not be created due to the following error:\n{str(_e)}') + except IntegrityError: + logger.warning(f'The user "{add_user}" could not be created') # do not try again settings.USER_ADDED = True diff --git a/InvenTree/label/apps.py b/InvenTree/label/apps.py index 0d6aa0f8b0..850e55c355 100644 --- a/InvenTree/label/apps.py +++ b/InvenTree/label/apps.py @@ -182,13 +182,15 @@ class LabelConfig(AppConfig): logger.info(f"Creating entry for {model} '{label['name']}'") - model.objects.create( - name=label['name'], - description=label['description'], - label=filename, - filters='', - enabled=True, - width=label['width'], - height=label['height'], - ) - return + try: + model.objects.create( + name=label['name'], + description=label['description'], + label=filename, + filters='', + enabled=True, + width=label['width'], + height=label['height'], + ) + except Exception: + logger.warning(f"Failed to create label '{label['name']}'") diff --git a/docker/production/.env b/docker/production/.env index c465f03a28..acbe0ae735 100644 --- a/docker/production/.env +++ b/docker/production/.env @@ -42,7 +42,7 @@ INVENTREE_DB_PORT=5432 #INVENTREE_CACHE_PORT=6379 # Options for gunicorn server -INVENTREE_GUNICORN_TIMEOUT=30 +INVENTREE_GUNICORN_TIMEOUT=90 # Enable custom plugins? INVENTREE_PLUGINS_ENABLED=False