chdsbd / kodiak

🔮 A bot to automatically update and merge GitHub PRs
https://kodiakhq.com
GNU Affero General Public License v3.0
1.03k stars 65 forks source link

Enable setting username for Redis #879

Closed androa closed 5 months ago

androa commented 6 months ago

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.

https://github.com/chdsbd/kodiak/blob/729e64dbc1211117a1d83aaccc0bcbd0967e550a/bot/kodiak/redis_client.py#L13-L18

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

chdsbd commented 6 months ago

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?

androa commented 6 months ago

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.