fix: a refused database move leaves the host as it was
CI / check (pull_request) Successful in 19s

On .50 a deploy refused by the database step had already copied the refused
version's compose files and written its NETORK_VERSION to .env: a hand-typed
`docker compose up -d` would have carried postgres back to the old volume.
The database step now runs before .env is written, the previous compose files
are kept as .prev while the new ones are fetched, and a refusal (exit 3) puts
them back. Checked on .50: checksums of both compose files and .env unchanged
after a refused deploy.
This commit is contained in:
Christian Manivong committed 2026-10-21 00:44:15 +02:00
1 parent 4d3a7eb1f4
commit 1e87478f7f
3 files changed
+56 -17

No files matched your search

+27
View File
@@ -82,3 +82,30 @@ def test_a_refusal_stops_the_deploy_before_the_engine(tmp_path: Path) -> None:
assert result.returncode != 0
assert not any("--force-recreate" in c for c in commands)
assert not any("redis" in c and "up -d" in c for c in commands)
def test_the_database_is_checked_before_env_names_the_new_version(tmp_path: Path) -> None:
"""A refused deploy must leave .env as it was: the check runs first."""
_, commands = _deploy(tmp_path)
env_write = next(i for i, c in enumerate(commands) if c.strip() == "bash -s")
assert _index(commands, "bash -s -- reconcile") < env_write
def test_the_previous_compose_files_are_kept_while_the_new_ones_are_fetched(tmp_path: Path) -> None:
_, commands = _deploy(tmp_path)
fetch = commands[_index(commands, "/app/deploy/")]
assert 'cp "$f" "$f.prev"' in fetch
def test_a_refusal_puts_the_previous_compose_files_back(tmp_path: Path) -> None:
"""Refused (exit 3) means nothing changed; the host's compose files must not
name the refused version either, or a hand-typed `docker compose up -d`
would carry the database to the other volume (seen on .50, 2026-10-21)."""
result, commands = _deploy(tmp_path, db_exit=3)
assert result.returncode != 0
restore = [c for c in commands if 'mv "$f.prev" "$f"' in c]
assert restore, "the previous compose files are not put back"
assert _index(commands, 'mv "$f.prev" "$f"') > _index(commands, "bash -s -- reconcile")