lifecycle: clean full redis as part of system migration

This commit is contained in:
Jens Langhammer 2020-12-12 23:29:45 +01:00
parent 6e55431d4c
commit d2862ddc93
1 changed files with 16 additions and 0 deletions

View File

@ -1,4 +1,7 @@
# flake8: noqa
from redis import Redis
from authentik.lib.config import CONFIG
from lifecycle.migrate import BaseMigration
SQL_STATEMENT = """BEGIN TRANSACTION;
@ -103,3 +106,16 @@ class Migration(BaseMigration):
def run(self):
self.cur.execute(SQL_STATEMENT)
self.con.commit()
# We also need to clean the cache to make sure no pickeled objects still exist
for db in [
CONFIG.y("redis.message_queue_db"),
CONFIG.y("redis.cache_db"),
CONFIG.y("redis.ws_db"),
]:
redis = Redis(
host=CONFIG.y("redis.host"),
port=6379,
db=db,
password=CONFIG.y("redis.password"),
)
redis.flushall()