Skip to content

fix(tools): compare container mounts in a fixed order in cleanup - #721

Closed
yifanxuaaa wants to merge 1 commit into
mainfrom
fix/cleanup-mount-order
Closed

yifanxuaaa wants to merge 1 commit into
mainfrom
fix/cleanup-mount-order

Conversation

@yifanxuaaa

Copy link
Copy Markdown
Contributor

Problem

docker container inspect lists a container's Mounts in no fixed order. The same stopped container came back in a different order in 1 of 6 inspects. tools/cleanup_docker.py compared the list as Docker returned it, so retiring a container failed at random, with either of these errors:

  • "Container identity or execution state changed since plan" (plan compared with apply), or
  • "Container changed during recovery capture" (after the recovery image was committed). This one leaves both the container and a recovery image behind.

Fix

identity() now sorts Mounts by Destination, which is unique within a container. Plan, apply and the post-capture check all go through identity(), so all three now see the same order.

Checks

  • Ruff 0.17.2 format --check and check: clean.
  • 12 inspects of one stopped container now give 1 distinct identity.

Production LOC: 102,831 -> 102,831 (delta 0). This changes tooling only.

🤖 Generated with Claude Code

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 498dd19)
  Method: tools/production_loc.py --detail; tooling-only change, parent 7d42d0b and the staged tree count the same

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yifanxuaaa

Copy link
Copy Markdown
Contributor Author

Not needed: layerfs_v2_0_0 already has this fix in 008cc85 (#626), and the owner wants it kept on layerfs_v2_0_0 only.

@yifanxuaaa yifanxuaaa closed this Nov 16, 2026
@yifanxuaaa
yifanxuaaa deleted the fix/cleanup-mount-order branch November 16, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant