Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.