The token store at /var/lib/infinito/secrets/tokens.yml survived
compose+volumes purges, so matrix-deploy variant transitions left a
stale matomo token in place. On the next round the token-empty guard
in sys-front-inj-matomo never fired and the public-URL probe hit an
empty openresty upstream, returning 502.
- utils/cleanup/tokens.py: wipes users.<user>.tokens.<app_id> entries
via utils.cache.yaml (load_yaml_any / dump_yaml).
- scripts/container/purge/apps.sh: app-keyed orchestrator that maps
$APPS to compose entities, drives entity/{db,compose,dir}.sh, and
invokes utils.cleanup.tokens for the same app set.
- scripts/tests/deploy/local/purge/entity.sh becomes a thin
docker-exec wrapper invoking apps.sh inside the runner.
- Drop scripts/container/purge/entity/all.sh; its trivial loop and
unused --wipe-data-only / --db-only flags fold into apps.sh.
- tests/unit/utils/cleanup/test_tokens.py covers wipe paths (single
app, multi-user, multi-app, no-match no-rewrite, missing file,
user-without-tokens, non-dict user) plus the __main__ shim.
- READMEs updated for the new layout.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
988 B
Cleanup Utilities 🧹
This directory contains helpers that mutate persistent on-host state during purge flows.
Scope 📋
Modules under utils/cleanup/ MUST limit themselves to wiping or normalising state that survives compose and volume purges (for example secrets, token stores, cached registry data) so the surrounding entity-keyed purge primitives stay focused on stack-level cleanup.
Modules under utils/cleanup/ MUST NOT take over responsibilities that belong to the entity-keyed purge primitives in scripts/container/purge/entity/ (database drop, compose down, filesystem removal).
Usage 🛠️
Every module here SHOULD expose a callable function for in-process use and a __main__ shim so the same code path is reachable from shell orchestrators via python -m utils.cleanup.<module>.
The host-side purge flow invokes these modules through the app-keyed orchestrator apps.sh.