From d2862ddc9399133513d569e5912717882fb41c2c Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 12 Dec 2020 23:29:45 +0100 Subject: [PATCH] lifecycle: clean full redis as part of system migration --- ...o_0_100_authentik.py => to_0_13_authentik.py} | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) rename lifecycle/system_migrations/{to_0_100_authentik.py => to_0_13_authentik.py} (94%) diff --git a/lifecycle/system_migrations/to_0_100_authentik.py b/lifecycle/system_migrations/to_0_13_authentik.py similarity index 94% rename from lifecycle/system_migrations/to_0_100_authentik.py rename to lifecycle/system_migrations/to_0_13_authentik.py index 7133e74e0..c566515e3 100644 --- a/lifecycle/system_migrations/to_0_100_authentik.py +++ b/lifecycle/system_migrations/to_0_13_authentik.py @@ -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()