Skip to content

Djangos collectstatic fails with DEBUG=True and no Redis service running #18515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tobiasge opened this issue Jan 28, 2025 · 0 comments · Fixed by #18516
Closed

Djangos collectstatic fails with DEBUG=True and no Redis service running #18515

tobiasge opened this issue Jan 28, 2025 · 0 comments · Fixed by #18516
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@tobiasge
Copy link
Member

Deployment Type

Self-hosted

NetBox Version

v4.2.2

Python Version

3.12

Steps to Reproduce

  1. Set DEBUG = True in configuration
  2. Stop any local Redis service
  3. run manage.py collectstatic (probably any other command also fails)

Expected Behavior

I expect the static files to be collected.
The reason for having DEBUG = True in the configuration is that the static files for the debug_toolbar Django app are only collected when the debug mode is on (see settings.py, line 416).

Observed Behavior

The management command fails with the error bellow. This is caused by core/apps.py, lines 30 and 31.

5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/cache.py", line 29, in _decorator
5.676     return method(self, *args, **kwargs)
5.676            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/cache.py", line 118, in clear
5.676     return self.client.clear()
5.676            ^^^^^^^^^^^^^^^^^^^
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/client/default.py", line 438, in clear
5.676     raise ConnectionInterrupted(connection=client) from e
5.676 django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
5.676
5.676 During handling of the above exception, another exception occurred:
5.676
5.676 Traceback (most recent call last):
5.676   File "/opt/netbox/netbox/manage.py", line 10, in <module>
5.676     execute_from_command_line(sys.argv)
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
5.676     utility.execute()
5.676   File "/opt/netbox/venv/lib/python3.12/site-packages/django/core/management/__init__.py", line 416, in execute
5.676     django.setup()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django/__init__.py", line 24, in setup
5.677     apps.populate(settings.INSTALLED_APPS)
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django/apps/registry.py", line 124, in populate
5.677     app_config.ready()
5.677   File "/opt/netbox/netbox/core/apps.py", line 31, in ready
5.677     cache.clear()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/cache.py", line 36, in _decorator
5.677     raise e.__cause__
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/django_redis/client/default.py", line 436, in clear
5.677     client.flushdb()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/commands/core.py", line 941, in flushdb
5.677     return self.execute_command("FLUSHDB", *args, **kwargs)
5.677            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/client.py", line 559, in execute_command
5.677     return self._execute_command(*args, **options)
5.677            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/client.py", line 565, in _execute_command
5.677     conn = self.connection or pool.get_connection(command_name, **options)
5.677                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/connection.py", line 1422, in get_connection
5.677     connection.connect()
5.677   File "/opt/netbox/venv/lib/python3.12/site-packages/redis/connection.py", line 363, in connect
5.677     raise ConnectionError(self._error_message(e))
5.677 redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
@tobiasge tobiasge added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels Jan 28, 2025
tobiasge added a commit to tobiasge/netbox that referenced this issue Jan 28, 2025
When no Redis server is reachable management commands failed without
this try...except block.
tobiasge added a commit to tobiasge/netbox that referenced this issue Jan 28, 2025
When no Redis server is reachable management commands failed without
this try...except block.
@bctiemann bctiemann added status: accepted This issue has been accepted for implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels Jan 28, 2025
bctiemann added a commit that referenced this issue Jan 28, 2025
@bctiemann bctiemann self-assigned this Jan 28, 2025
bctiemann pushed a commit that referenced this issue Jan 28, 2025
When no Redis server is reachable management commands failed without
this try...except block.
bctiemann pushed a commit that referenced this issue Jan 29, 2025
When no Redis server is reachable management commands failed without
this try...except block.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants