fix(adapters): detect untagged database images in backup autodetection - #413
Open
shuvamk wants to merge 1 commit into
Open
fix(adapters): detect untagged database images in backup autodetection#413shuvamk wants to merge 1 commit into
shuvamk wants to merge 1 commit into
Conversation
`image: postgres` with no tag is valid compose and is stored verbatim on the service row, but all four database producers required a colon after the image name, so `auto` fell through to the crash-consistent volume tar instead of running a logical dump. Measured through `autoDetectProducer` with the real registry loaded: postgres:16 -> pg_dump postgres -> volume mysql:8.0 -> mysql_dump mysql, mariadb -> volume mongo:7 -> mongo_dump mongo -> volume redis:7 -> redis_rdb redis -> volume postgis/postgis and percona/percona-server(-mongodb) untagged -> volume The dashboard's policy editor renders "Detected PostgreSQL - Auto backs it up with pg_dump" for `image: postgres` while the run tars a live PGDATA, and it offers only auto / volume / custom_command, so there is no way to ask for the dump. Each regex gains `$` as an alternative terminator to `:` and nothing else. The end anchor is the whole change: `/` is deliberately NOT added to the postgres, mysql and mongo patterns, because that would pull in the entire `<db>/<repo>` namespace - `mysql/mysql-router` is a proxy with no data and no `mysqldump` binary, and its documented compose env carries MYSQL_PASSWORD, so it would satisfy the credential guard, fail the dump, and turn a green zero-artifact run red. Redis keeps the `/` it already had, which `redis/redis-stack` relies on. The image match widens by exactly the untagged spelling; nothing else does. The env guards are untouched, so an untagged `postgres` with no `POSTGRES_DB`/`PGDATABASE` still falls back to volume. A digest reference (`postgres@sha256:...`) resolves to volume as before, an image that merely starts with a database name is unaffected (`postgrest`, `postgresql`, `postgres-exporter`, `myapp/postgres`, `mysqld-exporter`, `mongo-express`, `redis-sentinel`, `redisinsight`), and `<db>/<repo>` forms (`mysql/mysql-server:8.0`, `mariadb/maxscale:23.08`, `postgres/whatever`) keep resolving to volume - pinned by a test that fails if the terminator is widened to `[:/]`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backup auto-detection required a tag on the service image, so
image: postgrestook a crash-consistent volume tar instead ofpg_dump. All four database producers now accept the untagged spelling.Motivation
image: postgreswith no tag is valid compose and is stored verbatim on the service row, but every producer gated on a colon after the image name. Measured throughautoDetectProducerwith the real registry:postgres:16postgresSame mechanism, same result for
mysql,mariadb,mongo,redis,postgis/postgisandpercona/percona-server(-mongodb): tagged detects, untagged falls through.A tar of a live PGDATA is crash-consistent, not app-consistent — not the backup the policy asked for, and nothing reports the downgrade. The policy editor already renders "Detected PostgreSQL — Auto backs it up with pg_dump" for
image: postgreswhile the run tars the volume, and it offers only auto / volume / custom_command, so there is no way to ask for the dump.Related issue
None.
Changes
producers/{pg-dump,mysql-dump,mongo,redis}.ts— each image regex gains$as an alternative terminator to:. EachDetection:header line is updated to the regex it describes.producers/detect.test.ts— new./is deliberately not added to the postgres, mysql and mongo patterns: that would admit the whole<db>/<repo>namespace, andmysql/mysql-routeris a proxy with no data and nomysqldumpbinary whose documented compose env carriesMYSQL_PASSWORD— it would satisfy the credential guard, fail the dump, and turn a green zero-artifact run red. Redis keeps the/it already had, whichredis/redis-stackrelies on.So the image match widens by exactly the untagged spelling. The env guards are untouched (untagged
postgreswith noPOSTGRES_DB/PGDATABASEstill falls back to volume); a digest referencepostgres@sha256:…still resolves to volume; andpostgrest,postgresql,postgres-exporter,myapp/postgres,redis-sentinel, plus every<db>/<repo>form, resolve tovolumebefore and after.Verification
Five tests in
detect.test.ts. The untagged case fails with only the source files reverted:The
<db>/<repo>test passes on main too, on purpose — it pins the boundary this change could have opened, and I checked it by inversion: widening the three terminators to[:/]makes that test, and only that test, fail.Full suite green,
tsc --noEmitclean inpackages/adaptersandapps/api.Checklist
bun run testandbun run --cwd packages/adapters lintpass locally. I did not run the repo-widebun format—prettier --checkalready fails on three of these files onorigin/mainand I did not want to churn that drift; I checked the files individually instead, and every line this PR adds is prettier-clean.