Repository navigation
Conversation
rzo1
left a comment
There was a problem hiding this comment.
Thanks @linzch3. With the shared working directory, the cleanup in pull_build's except block can now delete earlier work: re-running pull-build for an image that already exists makes skopeo_copy_image fail, and shutil.rmtree(skopeo_dir) then removes the previous run's directory with its .sqsh files. The same happens within one run for two images with the same basename. Could you only remove skopeo_dir when this run created it? Also, a short note on the new reuse behaviour in the --working-dir help would be helpful.
A failed pull-build re-run must not delete a pre-existing skopeo_dir and its .sqsh files. Also mention the reuse behaviour in the --working-dir help.
|
thx for catching this. u're right that a failed pull-build re-run (or two images with the same basename) could wipe an earlier skopeo_dir and its .sqsh files. i now only remove the directory when this run created it, and i added a short note on the reuse behaviour in the --working-dir help. |
…rking-dir # Conflicts: # bin/test_docker_to_squash.py
What is the purpose of the change
Fixes #9292.
get_working_dirnever reuses a directory: ifdts-work-direxists it createsdts-work-dir/docker-to-squashinstead.pull-buildcalls it once per image, so the 1st image goes todts-work-dir, the 2nd todts-work-dir/docker-to-squash, and the 3rd fails with[Errno 17] File exists. Andpush-updatethen looks underdts-work-dir/docker-to-squashand doesn't find whatpull-buildpulled.I kept the subdirectory behavior as the default on purpose: most commands (
pull-build-push-update,remove-image,add-remove-tag, ...)rm -rftheir working directory at the end, so they shouldn't take over an existing directory like--working-dir /tmp.Changes:
get_working_dir(directory, reuse=False): withreuse=Trueit creates the directory if needed (exist_ok=True) and returns it as is.pull_buildandpush_updatepassreuse=True. Neither of them removes the working directory, and they're meant to be run one after the other on the same--working-dir.How was the change tested
python -m unittest -v test_docker_to_squashinbin/with Python 3.9: passes.get_working_dir(..., reuse=True)3 times returns the same dir; the default still uses a subdirectory of an existing dir; and apull_buildrun over 3 images (skopeo/manifest calls mocked) puts all of them directly under the working dir, after whichpush_updatelooks fordts-work-dir/ubuntu:22.04/manifest.json. With the fix reverted, the pull/push test fails with[Errno 17] File exists: '.../dts-work-dir/docker-to-squash'.An AI assistant helped draft this change; I reviewed it and take responsibility for it.