Suor / django-cacheops

A slick ORM cache with automatic granular event-driven invalidation.
BSD 3-Clause "New" or "Revised" License
2.12k stars 227 forks source link

Unable to provide password to master redis client on Sentinel Integration. #391

Closed AnveshGoud closed 3 years ago

AnveshGoud commented 3 years ago

There should be option to provide password in case redis instance needs password over sentinel.

I work in an environment where password is required for both sentinel master and redis master.

there should be possibility to pass password value for below snippet in redis_client method, cacheops/redis.py

sentinel.master_for(
            settings.CACHEOPS_SENTINEL['service_name'],
            redis_class=client_class,
            db=settings.CACHEOPS_SENTINEL.get('db', 0),

        )
Suor commented 3 years ago

cacheops passes CACHEOPS_SENTINEL argument as is mostly. If Sentinel constructor provides a way to pass a password then you just add the same thing to CACHEOPS_SENTINEL. If it doesn't it is redis-py issue.

Suor commented 3 years ago

I looked at Sentinel constructor code and looks like it has sentinel_kwargs for this.

AnveshGoud commented 3 years ago

@Suor But the password is not for sentinel and could be different. And master_for takes password as a parameter. We have fixed it in our code as below

sentinel.master_for(
            settings.CACHEOPS_SENTINEL['service_name'],
            redis_class=client_class,
            db=settings.CACHEOPS_SENTINEL.get('db', 0),
           password='password'
        )

Sentinel constructor code and looks like it hassentinel_kwargsfor this.

This works only if Sentinel has authorisation but not redis master and there is no issue in using that

Suor commented 3 years ago

From reading Sentinel.__init__() code I see that you can pass both sentinel_kwargs["password"] and password.