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

Does redis-on-python support sentinel connections? #589

Closed
BigDuke6nc opened this issue Jan 24, 2024 · 3 comments
Closed

Does redis-on-python support sentinel connections? #589

BigDuke6nc opened this issue Jan 24, 2024 · 3 comments

Comments

@BigDuke6nc
Copy link

I have been trying to get a connection to the master after getting it from the sentinel using sentinel.master_for()

This returns a Redis client as far as I can tell but when I try to set the Meta database to the return value I get connecting to localhost:6379. Connection refused. The connection is ignoring the master connection I am getting back from the sentinel. Whenever I connect using the same connection info and do a master.json().set() I have no issues. Can we not use this OM package in sentinel environment?

@slorello89
Copy link
Member

Hi @BigDuke6nc - I'm combing through the backlog and saw this issue

As far as I can tell it doesn't look like Redis OM was ever set up to receive sentinel clients (which it needs in order to connect to them correctly).

For some background the target environment for Redis OM is Redis Cloud/Redis Enterprise both of which achieve HA without a client needing to hassle with Sentinel connections. This isn't meant to be a sales pitch (though feel free to buy our products), nor is that to say we'd never support it, there just is pretty minimal demand for sentinel in general. Going to leave this open for now.

@DennyD17
Copy link

I use Sentinel and there are no issues with it

models:

_redis = get_redis(
    APP_CONFIG["REDIS_CONF"], sentinel_master=APP_CONFIG.get("REDIS_SENTINEL_MASTER")
)

class MyModel(JsonModel):
    class Meta:
        database = _redis

piece of get_redis:

        sentinel = Sentinel(redis_conf, **extra_redis_conf)
        if use_master or os.getenv("USE_REDIS_MASTER"):
            r = sentinel.master_for(sentinel_master, socket_timeout=timeout)
        else:
            r = sentinel.slave_for(sentinel_master, socket_timeout=timeout)
        return r

@slorello89
Copy link
Member

Thanks for answer @DennyD17 - looks like this should work for you @BigDuke6nc - feel free to re-open if it doesn't

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

3 participants