Browse Source

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 <noreply@anthropic.com>
rate-limiter-2026
Edward Ribeiro 3 weeks ago
parent
commit
faf648bebc
  1. 7
      docker/startup_scripts/start.sh

7
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).

Loading…
Cancel
Save