From 57daf559f01e708fbd1d480b5299e163083894b7 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 9 Oct 2026 23:44:55 +0200 Subject: [PATCH 1/5] we are currently locking on olugin lease for 2 mins per ci setup; not good --- .github/actions/migration/action.yaml | 2 ++ .github/actions/setup/action.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/actions/migration/action.yaml b/.github/actions/migration/action.yaml index 2c06172153f1..909f00fa95f1 100644 --- a/.github/actions/migration/action.yaml +++ b/.github/actions/migration/action.yaml @@ -4,6 +4,8 @@ author: 'InvenTree' runs: using: 'composite' + environment: + SETUP_INITIALIZING=1 steps: - name: Data Import Export shell: bash diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml index 6000656c311c..3ea38331a0a1 100644 --- a/.github/actions/setup/action.yaml +++ b/.github/actions/setup/action.yaml @@ -37,6 +37,8 @@ inputs: runs: using: 'composite' + environment: + SETUP_INITIALIZING=1 steps: - name: Checkout Code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 From acfa60d1c77bb1c02d8512ca4427d66cd48cbe19 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 9 Oct 2026 23:55:36 +0200 Subject: [PATCH 2/5] fix syntax --- .github/actions/migration/action.yaml | 4 ++-- .github/actions/setup/action.yaml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/actions/migration/action.yaml b/.github/actions/migration/action.yaml index 909f00fa95f1..fd7743b563e4 100644 --- a/.github/actions/migration/action.yaml +++ b/.github/actions/migration/action.yaml @@ -4,8 +4,6 @@ author: 'InvenTree' runs: using: 'composite' - environment: - SETUP_INITIALIZING=1 steps: - name: Data Import Export shell: bash @@ -17,3 +15,5 @@ runs: invoke migrate invoke import-records -c -f data.json --strict invoke import-records -c -f data.json --strict + env: + SETUP_INITIALIZING=1 diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml index 3ea38331a0a1..768661fe6b39 100644 --- a/.github/actions/setup/action.yaml +++ b/.github/actions/setup/action.yaml @@ -37,8 +37,9 @@ inputs: runs: using: 'composite' - environment: - SETUP_INITIALIZING=1 + env: + SETUP_INITIALIZING=1 + steps: - name: Checkout Code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 From ceeb6e83a345402ba7449bdb279eadf709a13bef Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Fri, 9 Oct 2026 23:59:34 +0200 Subject: [PATCH 3/5] move setting --- .github/actions/setup/action.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml index 768661fe6b39..776ab224ae02 100644 --- a/.github/actions/setup/action.yaml +++ b/.github/actions/setup/action.yaml @@ -37,8 +37,6 @@ inputs: runs: using: 'composite' - env: - SETUP_INITIALIZING=1 steps: - name: Checkout Code @@ -100,15 +98,23 @@ runs: if: ${{ inputs.dev-install == 'true' || inputs.install == 'true' }} shell: bash run: invoke install --dev + env: + SETUP_INITIALIZING=1 - name: Run invoke install if: ${{ inputs.install == 'true' }} shell: bash run: invoke install + env: + SETUP_INITIALIZING=1 - name: Run invoke update if: ${{ inputs.update == 'true' }} shell: bash run: invoke update --skip-backup --skip-static --no-frontend + env: + SETUP_INITIALIZING=1 - name: Collect static files if: ${{ inputs.static == 'true' }} shell: bash run: invoke static --skip-plugins + env: + SETUP_INITIALIZING=1 From c6ee2f10970f9235c4b4901a2034b15a0c253303 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Sat, 10 Oct 2026 00:01:45 +0200 Subject: [PATCH 4/5] fix assign syntax --- .github/actions/migration/action.yaml | 2 +- .github/actions/setup/action.yaml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/actions/migration/action.yaml b/.github/actions/migration/action.yaml index fd7743b563e4..4a2aee0c7c63 100644 --- a/.github/actions/migration/action.yaml +++ b/.github/actions/migration/action.yaml @@ -16,4 +16,4 @@ runs: invoke import-records -c -f data.json --strict invoke import-records -c -f data.json --strict env: - SETUP_INITIALIZING=1 + SETUP_INITIALIZING: 1 diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml index 776ab224ae02..15445fbe082a 100644 --- a/.github/actions/setup/action.yaml +++ b/.github/actions/setup/action.yaml @@ -99,22 +99,22 @@ runs: shell: bash run: invoke install --dev env: - SETUP_INITIALIZING=1 + SETUP_INITIALIZING: 1 - name: Run invoke install if: ${{ inputs.install == 'true' }} shell: bash run: invoke install env: - SETUP_INITIALIZING=1 + SETUP_INITIALIZING: 1 - name: Run invoke update if: ${{ inputs.update == 'true' }} shell: bash run: invoke update --skip-backup --skip-static --no-frontend env: - SETUP_INITIALIZING=1 + SETUP_INITIALIZING: 1 - name: Collect static files if: ${{ inputs.static == 'true' }} shell: bash run: invoke static --skip-plugins env: - SETUP_INITIALIZING=1 + SETUP_INITIALIZING: 1 From 3e446d52097b6c51a70f55cd54734e4d75221a5a Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Sat, 10 Oct 2026 00:13:33 +0200 Subject: [PATCH 5/5] reduce noice while setting up --- src/backend/InvenTree/InvenTree/settings.py | 1 + src/backend/InvenTree/plugin/lease.py | 4 ++-- src/backend/InvenTree/plugin/registry.py | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/backend/InvenTree/InvenTree/settings.py b/src/backend/InvenTree/InvenTree/settings.py index 073a83a2427d..24a2264d79c7 100644 --- a/src/backend/InvenTree/InvenTree/settings.py +++ b/src/backend/InvenTree/InvenTree/settings.py @@ -235,6 +235,7 @@ PLUGIN_TESTING_EVENTS = False # Flag if events are tested right now PLUGIN_TESTING_EVENTS_ASYNC = False # Flag if events are tested asynchronously PLUGIN_TESTING_RELOAD = False # Flag if plugin reloading is in testing (check_reload) +SETUP_INITIALIZING = os.environ.get('SETUP_INITIALIZING', '0') == '1' # Plugin development settings PLUGIN_DEV_SLUG = get_setting('INVENTREE_PLUGIN_DEV_SLUG', 'plugin_dev.slug') diff --git a/src/backend/InvenTree/plugin/lease.py b/src/backend/InvenTree/plugin/lease.py index 6dfa53144afc..5af423a38674 100644 --- a/src/backend/InvenTree/plugin/lease.py +++ b/src/backend/InvenTree/plugin/lease.py @@ -4,11 +4,11 @@ without holding a database transaction open for the duration. """ -import os import time from datetime import datetime, timedelta from typing import Optional +from django.conf import settings from django.db import transaction from django.db.utils import IntegrityError, OperationalError, ProgrammingError from django.utils import timezone @@ -82,7 +82,7 @@ def acquire_lease_blocking( """ deadline = time.monotonic() + timeout - if os.environ.get('SETUP_INITIALIZING', '0') == '1': + if settings.SETUP_INITIALIZING: logger.debug("Skipping lease acquisition for '%s' during initialization", key) return True diff --git a/src/backend/InvenTree/plugin/registry.py b/src/backend/InvenTree/plugin/registry.py index a9337c9ac170..416b087a32e0 100644 --- a/src/backend/InvenTree/plugin/registry.py +++ b/src/backend/InvenTree/plugin/registry.py @@ -227,6 +227,10 @@ def get_plugin_configs(self) -> Optional[dict[str, Any]]: dict[str, PluginConfig]: Mapping of plugin slug to PluginConfig instance. None if the database is not ready to be queried. """ + # skip if the setup is initializing + if settings.SETUP_INITIALIZING: + return None + # As we have already checked the registry hash, this is a valid cache key cache_key = f'plugin_configs:{self.registry_hash}' @@ -518,8 +522,10 @@ def reload_plugins( self.update_plugin_hash() logger.info('Plugin Registry: Loaded %s plugins', len(self.plugins)) - # Ensure that each loaded plugin has a valid configuration object in the database - for plugin in self.plugins.values(): + # Ensure that each loaded plugin has a valid configuration object in the database; skip if setup is initializing + for plugin in ( + self.plugins.values() if not settings.SETUP_INITIALIZING else [] + ): if config := self.get_plugin_config(plugin.slug): # Ensure mandatory plugins are marked as active if config.is_mandatory() and not config.active: