chdsbd / kodiak

đŸ”® A bot to automatically update and merge GitHub PRs

Home Page:https://kodiakhq.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enable setting username for Redis

androa opened this issue · comments

I'm trying to set up self-hosted Kodiak, but I'm not able to make it connect to the Redis instance.

My Redis instance is dependent on both username and password, but it seems like this snippet of code is overriding the username and password I set in the URL.

return redis.Redis(
host=conf.REDIS_URL.hostname or "localhost",
port=conf.REDIS_URL.port or 6379,
password=conf.REDIS_URL.password,
ssl=conf.REDIS_URL.scheme == "rediss",
db=redis_db,

Would be possible to expand this to include the possiblity of setting username as well?

Yeah, it'd probably be a simple change:

diff --git a/bot/kodiak/redis_client.py b/bot/kodiak/redis_client.py
index 524da4b..2d64145 100644
--- a/bot/kodiak/redis_client.py
+++ b/bot/kodiak/redis_client.py
@@ -14,6 +14,7 @@ def create_connection() -> "redis.Redis[bytes]":
         host=conf.REDIS_URL.hostname or "localhost",
         port=conf.REDIS_URL.port or 6379,
         password=conf.REDIS_URL.password,
+        username=conf.REDIS_URL.username or "default",
         ssl=conf.REDIS_URL.scheme == "rediss",
         db=redis_db,
         socket_keepalive=True,

Out of curiosity, how are you running Redis so that it's not using the default username?

Yep, that did it. Used sed to replace it inline while building the image and it worked great.

I'm running it on a custom PaaS, built on top of Kubernetes, which provisions Redis instances through Aiven.