Keep one rollback tag derived from original release

This commit is contained in:
渡口浪人
2026-10-11 17:15:56 +08:00
parent b41163965e
commit df1eba74e8
3 changed files with 41 additions and 6 deletions
+6 -2
View File
@@ -98,6 +98,7 @@ def test_preflight_rejects_wrong_host_resources(tool, monkeypatch, change):
def test_deploy_rolls_back_exact_baseline_without_deleting_data(
tool, monkeypatch, failure
):
tool.old_image_tag = "pigway-frame-flow:release-" + "a" * 40 + "-" + "b" * 8
old = {"services": {"pigway-frame-flow": {"image": "sha256:previous"}}}
new = {"services": {"pigway-frame-flow": {"image": "candidate"}}}
activated, calls, saved = [], [], []
@@ -138,6 +139,7 @@ def test_deploy_rolls_back_exact_baseline_without_deleting_data(
assert cleanup == ["success"]
assert activated == [new]
assert saved[-1]["status"] == "success"
assert saved[-1]["rollback_tag"] == tool.old_image_tag + "-rollback"
assert not any(
isinstance(c, tuple) and ("down" in c or "prune" in c) for c in calls
)
@@ -255,9 +257,10 @@ def test_image_retention_protects_containers_rollback_and_other_tags(tool, monke
tool.state = {"previous_image": "previous"}
release = "pigway-frame-flow:release-" + "a" * 40 + "-" + "b" * 8
rollback = "pigway-frame-flow:rollback-" + "c" * 32
tool.state["rollback_tag"] = release + "-rollback"
images = [
{"Id": "current", "RepoTags": [release]},
{"Id": "previous", "RepoTags": [rollback]},
{"Id": "previous", "RepoTags": [release + "-rollback", release, rollback]},
{"Id": "stopped", "RepoTags": [release]},
{"Id": "obsolete", "RepoTags": [release, rollback]},
{"Id": "shared", "RepoTags": [release, "other:latest"]},
@@ -282,7 +285,8 @@ def test_image_retention_protects_containers_rollback_and_other_tags(tool, monke
monkeypatch.setattr(tool, "run", run)
tool.cleanup_images()
assert [c for c in calls if c[:2] == ("image", "rm")] == [
("image", "rm", release, rollback)
("image", "rm", release, rollback),
("image", "rm", release, rollback),
]