Repository navigation
feat(silo): deploy the single-container image and add silo-migrate - #581
After-Shock wants to merge 5 commits into
Conversation
|
As mentioned to you on discord this will need to follow the updated instructions for agents. |
Understood was just waiting on your agents.md changes. |
Silo now publishes one image under its plain tags, with PostgreSQL and Redis bundled and supervised by s6. The role runs it with /config under the Silo appdata folder, PUID/PGID instead of a container user, and no separate Postgres or Redis containers. The generated secret key is exposed as silo_role_secret_key. Existing multi-container installs are refused until they are migrated, so Silo never starts on an empty database. Completion is checked in the copied database itself: its bootstrap role must be silo and its users table must have records.
`sb install sandbox-silo-migrate` moves an existing install into the single-container layout with Silo's own migrate-compose-stack script. The legacy cluster is mounted read-only and is never modified; Silo's plugins, artwork and compat folders are hard-linked. The copied cluster's bootstrap role is renamed to silo, the role the bundled PostgreSQL authenticates, so Silo's migrations can alter the existing tables. Row counts for users, media items and watch history are compared before and after, and the legacy Postgres container is removed only once they match.
ad3467e to
61e6e8b
Compare
saltydk
left a comment
There was a problem hiding this comment.
Review: migration must preserve every override the legacy role honoured
The single-container role and the migration flow look solid: the announcement is append-only, containers are removed before the backend import, shm_size/stop_timeout go through the shared create task, and upstream's migrate-compose-stack refuses to copy while postmaster.pid exists. The blocking problem is that silo_migrate does not resolve the legacy settings the way the legacy silo role did, so some user overrides are silently replaced by defaults.
Why
The legacy role read every setting through lookup('role_var', '_x', role='silo'), which checks silo_x first and then silo_role_x. silo_migrate reads silo_role_x | default(...), which only sees the second form. The legacy PostgreSQL path default was also server_appdata_path/<silo_role_postgres_paths_folder>/postgres (independent of the main appdata folder), whereas the migrate default derives it from silo's _paths_location.
Verified resolution (legacy role at 05056d0d vs this PR)
Resolved with the Saltbox role_var plugin, loading postgres, silo and silo_migrate defaults, with each variant in its own process:
| Inventory override | Legacy role used | PR's silo_migrate uses |
With the suggested fix |
|---|---|---|---|
| none | silo-postgres / user.name / silo / pg18 / /opt/silo/postgres |
same | same |
silo_role_postgres_* (name, user, db, tag, location) |
the override | the override | the override |
silo_postgres_name: silodb, silo_postgres_user: foo, silo_postgres_docker_env_db: foodb, silo_postgres_docker_image_tag: pg17, silo_redis_name: silokv |
the override | defaults (silo-postgres, user.name, silo, pg18, silo-redis) |
the override |
silo_postgres_paths_location: /mnt/fast/silo-pg |
/mnt/fast/silo-pg |
/opt/silo/postgres |
/mnt/fast/silo-pg |
silo_role_postgres_paths_folder: silo-db |
/opt/silo-db/postgres |
/opt/silo/postgres |
/opt/silo-db/postgres |
silo_role_paths_folder: silo-server |
/opt/silo/postgres |
/opt/silo-server/postgres |
/opt/silo/postgres |
Consequences
- Wrong path:
sandbox-silo-migratefails with "No legacy Silo PostgreSQL data was found. Run 'sb install sandbox-silo' for a new installation", whilesandbox-silorefuses becauseplugins/exists. The user is stuck in a loop. - Wrong user or database:
Read legacy Silo row countsfails after the Silo container has already been removed. Upstream's script also depends on these values: it probesPOSTGRES_USERand renames a non-siloPOSTGRES_DBtosilo. - Wrong container name (most serious): the role starts a second
silo-postgreson the same data directory while the user's real legacy container is still running. PostgreSQL's lock-file check does not work across containers, because both postmasters are normally PID 1. Stopping the duplicate removespostmaster.pid, so upstream's "still running" guard passes and it copies a live cluster. This follows from how PostgreSQL's lock check works in containers; it has not been reproduced. - Overridden Silo container name: the migrate removes, waits on and execs into
silo_namerather than the configured container. See the inline comment.
Requested changes
- Resolve every legacy setting in
roles/silo_migrate/defaults/main.ymlwithlookup('role_var', '_x', role='silo', default=<legacy default>), and reproduce the legacy path formula (inline suggestions below). - Use the resolved values in tasks:
_postgres_paths_folderand the Silo_docker_container. - Handle the external-database settings (
silo_role_postgres_deploy: false,silo_role_database_url) explicitly, at least with an accurate failure message. - Optional cleanup: replace the
set_factwith a_lookupdefault.
With suggestions 1 and 2 applied, saltbox-lint check . (v0.2.7) and ansible-lint roles/silo_migrate both pass with no findings.
koito_migrate uses the same koito_role_x | default() pattern and has the same gap, but that is outside this PR.
Read every legacy setting with role_var against the silo role and the legacy defaults, so silo_x overrides are honoured as well as silo_role_x. The legacy PostgreSQL location is rebuilt from silo_role_postgres_paths_folder instead of Silo's appdata folder, and the configured Silo container name is used to remove, wait on and query Silo. Installs that used an external database are refused by both roles with an explicit message instead of being sent to a migration that cannot succeed. The PostgreSQL user is a _lookup default instead of a set_fact.
saltydk
left a comment
There was a problem hiding this comment.
Thanks for 8fcd60a. I checked it on my side:
- The legacy-setting lookups now resolve to the same values as the legacy role for every override form I tried:
silo_role_*,silo_*, the PostgreSQL folder, the main appdata folder, the global postgres user, and an emptysilo_role_postgres_user. - The container-name, folder and
_lookupchanges are correct. - The
announcements.ymldiff against master only adds lines.
Two follow-ups remain on the external-database handling, both inline. I think both are worth fixing in this PR, because upstream already supports the case.
- The refusal is a dead end, and upstream doesn't need one. The omnibus image turns its bundled PostgreSQL off when
DATABASE_URLis set, andmigrate-compose-stackmoves onlyplugins,artworkandcompatwhenDATABASE_URLnames an external database. External installs can therefore be carried over instead of refused. - Any
silo_role_database_urlis currently treated as external, including a URL that points at the legacysilo-postgrescontainer. Upstream's script refuses that case with "remove it to use the bundled one"; the roles should do the same.
@keldian, could you weigh in on the docs side (saltyorg/docs#433)? Specifically: should the Silo page describe the external-database path (keep silo_role_database_url, run the migrate tag to move the app folders), or link to upstream's omnibus docs for it? And where should the note about removing a silo_role_database_url that points at the old silo-postgres container go?
silo_role_database_url is a setting again, empty for the bundled database. When it is set, Silo gets it as DATABASE_URL, which turns the image's own PostgreSQL off, and silo-migrate runs upstream's script with that URL and without the legacy cluster mounts, so only plugins, artwork and compat move. The legacy PostgreSQL steps are skipped for these installs, and the silo role checks for the moved plugins folder instead of the copied database. A URL that points at the legacy PostgreSQL container is refused by both roles before anything is removed, as upstream's script does.
|
…tead of rc inference ansible-core 2.22 deprecates inferring a task failure from a non-zero rc. The legacy and migrated row count reads now state it, as 1f8d01f did for the other docker_container_exec tasks.
Description
Silo now publishes a single image under its plain tags (
latest,build-N,<sha>), with PostgreSQL and Redis bundled and supervised by s6 (Silo-Server/silo-server#3319, 2026-10-31). The split-container layout that #575 found hard to keep up with is no longer needed, and the role as last shipped can't run the current image (/initneeds root, anduser:was set).This brings the role back on that image and adds a migration for existing installs.
siloghcr.io/silo-server/silo-server:latestwith/opt/silo/configmounted at/config,PUID/PGID, andENABLE_REDIS=true. There's no containeruser:.postgresandredissub-roles and the dependency settings.silo-postgreshad and sets a 120s stop timeout, matching the upstream Compose file.silo_role_secret_keyand validates it before deploying./opt/silo/postgresor/opt/silo/plugins) without a completed migration, so Silo never comes up on an empty database. Completion is read from the copied database, not a marker file: with Silo stopped, a one-off container starts the bundled PostgreSQL with no network and checks that the bootstrap role issiloand thatusershas records.silo_migrate(sb install sandbox-silo-migrate,nevertag, same pattern askoito_migrate)users,media_items,user_watch_historyanduser_watch_progress, then stopssilo-postgresand removessiloandsilo-redis./etc/silo-omnibus/migrate-compose-stackin a one-off container with no network. The old cluster is mounted read-only. The script copies it and hard-linksplugins,artworkandcompatintoconfig/silo.silo. The bundled PostgreSQL authenticates Silo assiloby peer, and upstream's script only adds a separatesilosuperuser whenPOSTGRES_USERdiffers. Without the rename, Silo's next migration fails withsequence must have same owner as table it is linked to.silo-postgresis removed only if they match.The copy is skipped when
/opt/silo/config/postgres/dataalready exists. The counts are read and compared again on every run while thesilo-postgrescontainer still exists, so a run that failed after the copy is validated when it is re-run.The old
/opt/silo/postgres,redis,plugins,artworkandcompatfolders are never modified. Re-running the tag after a successful migration only redeploys Silo.Legacy settings are read the way the legacy role read them (
lookup('role_var', '_x', role='silo', default=<legacy default>)), so bothsilo_xandsilo_role_xoverrides are honoured. The legacy PostgreSQL location followssilo_role_postgres_paths_folder, and the configuredsilo_role_docker_containeris used throughout.External databases.
silo_role_database_urlis a setting again, in aPostgressection, and is empty by default, meaning the bundled database. When it is set, Silo gets it asDATABASE_URL, which turns the image's own PostgreSQL off. For these installs,silo-migrateruns upstream's script with that URL and without the legacy cluster mounts, so onlyplugins,artworkandcompatmove. The PostgreSQL steps (count read, stop, role rename, count comparison) are skipped, and the legacy Redis container is still removed. Thesilorole checks forconfig/silo/pluginsinstead of the copied database. A URL whose host is the legacy PostgreSQL container (or localhost) is refused by both roles before anything is removed, as upstream's script does.silo_role_postgres_deploy: falsewith no URL fails with a message asking for the URL.silo_migrateis registered underNo CIwith thenevertag and listed inignored_rolesin.github/ci-role-matrix.yml, likekoito_migrate.A new announcement describing the migration is appended to
announcements.yml; the existing entries are unchanged. Docs: saltyorg/docs#433Validation
Static
Run against this branch rebased on 05056d0:
ansible-lint: passed, production profile.saltbox-lint check .(v0.2.7): no findings.git diff --check: clean../scripts/check_missing_entries.py: passed.Live
On a disposable Ubuntu 24.04 test VM with Saltbox 47ae993 and this branch in
/opt/sandbox. The legacy data was created earlier by deploying the role as of 5999d5a with the last pre-omnibus image (7ee9615f), then seeding an admin user, a profile, a Movies library (3 items) and 2 watched items through Silo's API.With the legacy data in place and no copied cluster,
sb install sandbox-silofailed with the migrate message, and the existingsilocontainer was not removed.sb install sandbox-silo-migrate:failed=0in about 2.5 minutes. Counts matched (1|3|2|2), the database check in the silo role passed, every public table is owned bysilo,silois the only non-system role, andsilo-postgreswas removed.Re-ran
sandbox-silo-migrate, thensandbox-silo: bothfailed=0. The copy and count steps were skipped, the database check passed and Silo was healthy with no errors in its log.Fresh install on an empty
/opt/silo:sandbox-silotwice, bothfailed=0, the database check skipped, Silo healthy.Review follow-up (8fcd60a), on the same VM reset to the legacy state:
silo_role_postgres_deploy: false:sandbox-siloandsandbox-silo-migrateboth fail with the external-database message. Same forsilo_database_urlwith the migrate tag./opt/silo-db/postgres, withsilo_role_postgres_paths_folder: silo-db,silo_postgres_name: silodb,silo_redis_name: silokv,silo_role_docker_container: silo-serverand a runningsilokvcontainer:sandbox-silo-migratefailed=0. It startedsilodbon/opt/silo-db/postgres(nosilo-postgresanywhere in the run), removedsilokv, waited onsilo-serveruntil healthy, counts matched (1|3|2|2), andsilodbwas removed.External-database follow-up (01417b5), on the same VM:
silo_role_database_urlpointing atSilo-Postgres(uppercase): both tags fail with the legacy-container message before removing anything.failed=0, counts matched, and the container has noDATABASE_URL.plugins,artworkandcompat, no legacy cluster, and a separatepgvector/pgvector:pg18container as the external database.sandbox-silorefused with the migrate message.sandbox-silo-migrategavefailed=0in about 1.5 minutes: the PostgreSQL steps were skipped, the folders were moved intoconfig/silo, and Silo came up healthy withDATABASE_URLset and no PostgreSQL process in the container. Silo created its 343 tables in the external database. Re-runningsandbox-silopassed.Not covered in this round
sandbox-silo-migrateon a fresh install, which should fail with "No legacy Silo PostgreSQL data was found". That task is unchanged and was tested before the rebase.silo|1andsilo|12pass;plex|1,silo|0, empty and error output fail) but did not break a real database to trigger it./opt/silo(a customsilo_role_postgres_paths_folderor location), Docker creates an empty, root-owned/opt/silo/postgresas the mount point for the migration's tmpfs. It's harmless: nothing reads it, and thesilorole checks forpostgres/PG_VERSION.