From 2451968f6af5361af714d6b4254a116862224ed8 Mon Sep 17 00:00:00 2001 From: YifanXu1999 Date: Mon, 16 Nov 2026 16:00:05 +0800 Subject: [PATCH] fix(tools): compare container mounts in a fixed order in cleanup docker container inspect lists a container's Mounts in no fixed order; the same stopped container came back with a different order in about one of six inspects. cleanup_docker.identity compared the list as given, so container retirement failed at random with "Container identity or execution state changed since plan" or "Container changed during recovery capture", leaving the container (and, in the second case, its recovery image) behind. identity() now sorts Mounts by Destination, which is unique within a container; twelve inspects of one container then give one identity. Production LOC: 102,831 -> 102,831 (delta 0) core 38,395 -> 38,395 (0) engine 61,777 -> 61,777 (0) api 2,659 -> 2,659 (0) reference absent (retired R9c; last counted 65,417 at tree 498dd1917812) Method: tools/production_loc.py --detail; tooling-only change, parent 7d42d0b506 and the staged tree count the same Co-Authored-By: Claude Opus 5.5 --- tools/cleanup_docker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/cleanup_docker.py b/tools/cleanup_docker.py index 629e470bca..0ad66599b7 100644 --- a/tools/cleanup_docker.py +++ b/tools/cleanup_docker.py @@ -16,8 +16,12 @@ def inspect(name): def identity(info): - return {key: info[key] for key in ("Id", "Created", "Image", "Config", "Mounts")} | { - "state": {key: info["State"][key] for key in ("Status", "Running", "StartedAt", "FinishedAt")} + # Docker reports Mounts in no fixed order; sort by destination (unique per + # container) so the same container compares equal across inspects. + mounts = sorted(info["Mounts"], key=lambda mount: mount["Destination"]) + return {key: info[key] for key in ("Id", "Created", "Image", "Config")} | { + "Mounts": mounts, + "state": {key: info["State"][key] for key in ("Status", "Running", "StartedAt", "FinishedAt")}, }