Netbox with Redis Sentinel - Issue when calling /api/status #5658

Closed
opened 2025-12-29 19:30:44 +01:00 by adam · 13 comments
Owner

Originally created by @smutel on GitHub (Nov 12, 2021).

NetBox version

v2.11.12

Python version

3.7

Steps to Reproduce

  1. Create a sentinel redis cluster
  2. Setup Netbox to use it
  3. Everything is working fine except when you want to access /api/status

Expected Behavior

To access /api/status correctly

Observed Behavior

Error below is displayed:

{"error": "No master found for 'master0'", "exception": "MasterNotFoundError", "netbox_version": "2.11.12", "python_version": "3.7.3"}
Originally created by @smutel on GitHub (Nov 12, 2021). ### NetBox version v2.11.12 ### Python version 3.7 ### Steps to Reproduce 1. Create a sentinel redis cluster 2. Setup Netbox to use it 3. Everything is working fine except when you want to access /api/status ### Expected Behavior To access /api/status correctly ### Observed Behavior Error below is displayed: ```json {"error": "No master found for 'master0'", "exception": "MasterNotFoundError", "netbox_version": "2.11.12", "python_version": "3.7.3"} ```
adam added the type: bugstatus: needs ownerpending closure labels 2025-12-29 19:30:44 +01:00
adam closed this issue 2025-12-29 19:30:44 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 12, 2021):

Could you try enabling debugging (set DEBUG=True in configuration.py and restart) to get the whole traceback from the exception please?

@jeremystretch commented on GitHub (Nov 12, 2021): Could you try enabling debugging (set `DEBUG=True` in `configuration.py` and restart) to get the whole traceback from the exception please?
Author
Owner

@smutel commented on GitHub (Nov 15, 2021):

Here is the traceback in debug mode:

Environment:


Request Method: GET
Request URL: https://netbox.xxx.xxx.xx/api/status/

Django Version: 3.2.6
Python Version: 3.7.3
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'cacheops',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'django_prometheus',
 'mptt',
 'rest_framework',
 'taggit',
 'timezone_field',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities',
 'virtualization',
 'django_rq',
 'drf_yasg']
Installed Middleware:
['debug_toolbar.middleware.DebugToolbarMiddleware',
 'django_prometheus.middleware.PrometheusBeforeMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'netbox.middleware.ExceptionHandlingMiddleware',
 'netbox.middleware.RemoteUserMiddleware',
 'netbox.middleware.LoginRequiredMiddleware',
 'netbox.middleware.APIVersionMiddleware',
 'netbox.middleware.ObjectChangeMiddleware',
 'django_prometheus.middleware.PrometheusAfterMiddleware']



Traceback (most recent call last):
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "./netbox/api/views.py", line 332, in get
    'rq-workers-running': Worker.count(get_connection('default')),
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rq/worker.py", line 131, in count
    return len(get_keys(queue=queue, connection=connection))
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rq/worker_registration.py", line 45, in get_keys
    return {as_text(key) for key in redis.smembers(redis_key)}
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/client.py", line 2281, in smembers
    return self.execute_command('SMEMBERS', name)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/client.py", line 898, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/connection.py", line 1192, in get_connection
    connection.connect()
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/sentinel.py", line 44, in connect
    self.connect_to(self.connection_pool.get_master_address())
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/sentinel.py", line 107, in get_master_address
    self.service_name)
  File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/sentinel.py", line 219, in discover_master
    raise MasterNotFoundError("No master found for %r" % (service_name,))

Exception Type: MasterNotFoundError at /api/status/
Exception Value: No master found for 'master0'
@smutel commented on GitHub (Nov 15, 2021): Here is the traceback in debug mode: ``` Environment: Request Method: GET Request URL: https://netbox.xxx.xxx.xx/api/status/ Django Version: 3.2.6 Python Version: 3.7.3 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.humanize', 'cacheops', 'corsheaders', 'debug_toolbar', 'django_filters', 'django_tables2', 'django_prometheus', 'mptt', 'rest_framework', 'taggit', 'timezone_field', 'circuits', 'dcim', 'ipam', 'extras', 'secrets', 'tenancy', 'users', 'utilities', 'virtualization', 'django_rq', 'drf_yasg'] Installed Middleware: ['debug_toolbar.middleware.DebugToolbarMiddleware', 'django_prometheus.middleware.PrometheusBeforeMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', 'netbox.middleware.ExceptionHandlingMiddleware', 'netbox.middleware.RemoteUserMiddleware', 'netbox.middleware.LoginRequiredMiddleware', 'netbox.middleware.APIVersionMiddleware', 'netbox.middleware.ObjectChangeMiddleware', 'django_prometheus.middleware.PrometheusAfterMiddleware'] Traceback (most recent call last): File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view return view_func(*args, **kwargs) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view return self.dispatch(request, *args, **kwargs) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 509, in dispatch response = self.handle_exception(exc) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 469, in handle_exception self.raise_uncaught_exception(exc) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception raise exc File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch response = handler(request, *args, **kwargs) File "./netbox/api/views.py", line 332, in get 'rq-workers-running': Worker.count(get_connection('default')), File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rq/worker.py", line 131, in count return len(get_keys(queue=queue, connection=connection)) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/rq/worker_registration.py", line 45, in get_keys return {as_text(key) for key in redis.smembers(redis_key)} File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/client.py", line 2281, in smembers return self.execute_command('SMEMBERS', name) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/client.py", line 898, in execute_command conn = self.connection or pool.get_connection(command_name, **options) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/connection.py", line 1192, in get_connection connection.connect() File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/sentinel.py", line 44, in connect self.connect_to(self.connection_pool.get_master_address()) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/sentinel.py", line 107, in get_master_address self.service_name) File "/opt/netbox/current/venv-py3/lib/python3.7/site-packages/redis/sentinel.py", line 219, in discover_master raise MasterNotFoundError("No master found for %r" % (service_name,)) Exception Type: MasterNotFoundError at /api/status/ Exception Value: No master found for 'master0' ```
Author
Owner

@smutel commented on GitHub (Nov 25, 2021):

Is-it enough or you need more logs ?

@smutel commented on GitHub (Nov 25, 2021): Is-it enough or you need more logs ?
Author
Owner

@jeremystretch commented on GitHub (Dec 8, 2021):

What leads you to believe this is a NetBox bug and not a Sentinel configuration/connectivity issue?

@jeremystretch commented on GitHub (Dec 8, 2021): What leads you to believe this is a NetBox bug and not a Sentinel configuration/connectivity issue?
Author
Owner

@smutel commented on GitHub (Dec 10, 2021):

You are right, I am not sure that it's a bug but I am not able to find the issue easily.
The error message is not enough clear to find the configuration issue if it's a configuration issue.

To help me on this topic, I have a question about the configuration:

  • PASSWORD is the password for redis ? for redis-sentinel ? for both ?

I join also the slack channel to get help on this and to see if it is a bug or a config issue.

@smutel commented on GitHub (Dec 10, 2021): You are right, I am not sure that it's a bug but I am not able to find the issue easily. The error message is not enough clear to find the configuration issue if it's a configuration issue. To help me on this topic, I have a question about the configuration: * `PASSWORD` is the password for redis ? for redis-sentinel ? for both ? I join also the slack channel to get help on this and to see if it is a bug or a config issue.
Author
Owner

@smutel commented on GitHub (Dec 10, 2021):

I just removed the sentinel password and it is working properly.
So I assume that PASSWORD is only for redis password and not for sentinel password.

Is-it possible to create a SENTINEL_PASSWORD in the config ?

@smutel commented on GitHub (Dec 10, 2021): I just removed the sentinel password and it is working properly. So I assume that `PASSWORD` is only for redis password and not for sentinel password. Is-it possible to create a SENTINEL_PASSWORD in the config ?
Author
Owner

@jeremystretch commented on GitHub (Dec 10, 2021):

The PASSWORD parameter is passed whether or not Sentinel is in use. There is no reason to introduce a redundant setting.

@jeremystretch commented on GitHub (Dec 10, 2021): The `PASSWORD` parameter is passed whether or not Sentinel is in use. There is no reason to introduce a redundant setting.
Author
Owner

@smutel commented on GitHub (Dec 10, 2021):

Redis and sentinel are two different processes. They could be protected by two different passwords.

Currently Netbox is able to work with a redis using a password but it is not able to work with a sentinel protected by a password.

@smutel commented on GitHub (Dec 10, 2021): Redis and sentinel are two different processes. They could be protected by two different passwords. Currently Netbox is able to work with a redis using a password but it is not able to work with a sentinel protected by a password.
Author
Owner

@jeremystretch commented on GitHub (Dec 10, 2021):

You're welcome to review the code in settings.py and propose a specific modification.

@jeremystretch commented on GitHub (Dec 10, 2021): You're welcome to review the code in [`settings.py`](https://github.com/netbox-community/netbox/blob/7922d3909a625a29cbef5b202f39634b7cf84b24/netbox/netbox/settings.py#L203) and propose a specific modification.
Author
Owner

@smutel commented on GitHub (Dec 10, 2021):

https://github.com/redis/redis-py/issues/1388

@smutel commented on GitHub (Dec 10, 2021): https://github.com/redis/redis-py/issues/1388
Author
Owner

@smutel commented on GitHub (Dec 11, 2021):

Thanks. I will try to implement this.

@smutel commented on GitHub (Dec 11, 2021): Thanks. I will try to implement this.
Author
Owner

@github-actions[bot] commented on GitHub (May 24, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions[bot] commented on GitHub (May 24, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Jun 30, 2022):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Jun 30, 2022): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5658