Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/migration/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,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
9 changes: 9 additions & 0 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ inputs:

runs:
using: 'composite'

steps:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down Expand Up @@ -97,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
1 change: 1 addition & 0 deletions src/backend/InvenTree/InvenTree/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions src/backend/InvenTree/plugin/lease.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions src/backend/InvenTree/plugin/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'

Expand Down Expand Up @@ -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:
Expand Down
Loading