fix: mount containerConfig volumes in the clone upgrade container

Clone major upgrade fails at the check stage on any instance whose databaseContainer.containerConfig adds volumes, which is the normal setup when TLS is on:

Upgrade was not applied. The clone is still running on PostgreSQL 16.
Cause: pg_upgrade failed with exit code 10 before converting anything

pg_upgrade_clone.log only reports could not connect to source postmaster. The real cause sits in pg_upgrade_server.log, which the engine deletes together with data_new on rollback:

FATAL:  could not load server certificate file "/var/lib/postgresql/cert/server.crt": No such file or directory
LOG:  database system is shut down
pg_ctl: could not start server

RunUpgradeContainer built its docker run from createDefaultVolumes/getMountVolumes alone and never appended c.ContainerConf, unlike RunContainer. pg_upgrade starts the old-major postmaster inside that container, the postmaster reads the clone's own config, and the certificate it names was not mounted.

The fix renders the same containerConfig flags the clone container gets. They come first so the upgrade container's own flags keep the last word, since docker resolves a repeated single-value flag to its last occurrence and the map is free-form.

The first commit is a pure refactor that makes the command a pure function, so the second commit is the one-line behaviour change plus its regression test.

Verification

Reproduced and bisected on demo.dblab.dev (engine v4.2.0-20260911-0242), one clone, cleanly shut down, one variable changed:

run volumes result
A the engine's current set could not connect to source postmaster, exit 1
B same + -v /var/lib/dblab/cert:/var/lib/postgresql/cert *Clusters are compatible*, exit 0

End to end with the patched code: the docker run this branch renders for demo's config was executed against a real clone there, and it converted it 16 → 17 — container exit code 0, Upgrade Complete, stage: done, .dblab_upgrade_done written, data_new/PG_VERSION = 17. Every test clone was deleted afterwards.

TestUpgradeRunCommandCarriesContainerConfig fails on master and passes here. Unit suite green, golangci-lint run ./... reports 0 issues.

Closes #792 (closed)

Merge request reports

Loading
Loading