Skip to content
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

Custom Redis settings not respected #13

Open
tacerus opened this issue May 4, 2024 · 3 comments
Open

Custom Redis settings not respected #13

tacerus opened this issue May 4, 2024 · 3 comments

Comments

@tacerus
Copy link

tacerus commented May 4, 2024

NetBox HealthCheck Plugin version

0.1.4

NetBox version

3.7.5

Python version

3.11

Steps to Reproduce

  1. Install the plugin
  2. Configure NetBox to use a Redis database other than localhost
  3. Query the healthcheck endpoint

Expected Behavior

It should use the Redis server and database specified in the REDIS section in configuration.py.

Observed Behavior

This plugin uses the default Redis adapter of the django-health-check module, which connects to redis://localhost:6379/1 by default, or to a REDIS_URL from settings.py.

NetBox does not expose REDIS_URL in the hidden settings.py, so the health check fails if any a database host and/or database number other than redis://localhost:6379/1 are used.

Currently I work around it with a hacky patch in django-health-check:

--- a/health_check/contrib/redis/backends.py    2024-05-03 23:37:27.000000000 +0200
+++ b/health_check/contrib/redis/backends.py    2024-05-04 22:11:02.448929656 +0200
@@ -12,7 +12,7 @@
 class RedisHealthCheck(BaseHealthCheckBackend):
     """Health check for Redis."""

-    redis_url = getattr(settings, "REDIS_URL", "redis://localhost/1")
+    redis_url = getattr(settings, "CACHES", {}).get("default", {}).get("LOCATION", getattr(settings, "REDIS_URL", "redis://localhost/1"))
@shepherdjay
Copy link

Even using above replacement running in docker-compose with the demo docker-compose setup on v3.5.4 Redis fails to work because of authentication issues.

Its not clear if this is the plugin issue to solve though -- its inheriting from django health which also has open issue on redis auth via documentation. -- revsys/django-health-check#279 - so probably needs to be solved by properly providing REDIS_URL in the core netbox maybe?

I'm not sure - was hoping this plugin would be a nice drop in for some health checking but I've been unable to get it to work.

@jsenecal
Copy link

Isnt that related to #12 ?

@llamafilm
Copy link

Yes, this sounds like a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants