From faf648bebc7ff9d54bc96f60f2fbaa46c7f30bbe Mon Sep 17 00:00:00 2001 From: Edward Oliveira Date: Tue, 14 Apr 2026 04:33:00 -0300 Subject: [PATCH] Fix configure_redis_cache overwriting operator-set waffle switch on restart waffle_switch REDIS_CACHE off --create always wrote 'off' even when the operator had previously enabled it, making docker compose restart always reset the switch and leaving Redis cache permanently disabled. Replace with a Django shell get_or_create call that only inserts the row with active=False on first boot; subsequent restarts leave the existing value untouched. Co-Authored-By: Claude Sonnet 4.6 --- docker/startup_scripts/start.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker/startup_scripts/start.sh b/docker/startup_scripts/start.sh index fa068a42f..00fdc5f89 100755 --- a/docker/startup_scripts/start.sh +++ b/docker/startup_scripts/start.sh @@ -339,10 +339,15 @@ resolve_cache_backend() { } # 3. Ensure the REDIS_CACHE waffle switch row exists (default: off). +# Uses get_or_create so the value is only set on first creation — +# subsequent restarts do NOT overwrite what the operator configured. +# (waffle_switch … off --create always writes off, breaking manual flips.) configure_redis_cache() { [[ -z "${REDIS_URL:-}" ]] && return 0 log "Ensuring REDIS_CACHE waffle switch exists (default: off)..." - python3 manage.py waffle_switch REDIS_CACHE off --create || true + python3 manage.py shell -c \ + "from waffle.models import Switch; Switch.objects.get_or_create(name='REDIS_CACHE', defaults={'active': False})" \ + || true } # 4. Block until Redis is reachable (or give up gracefully).