Repository navigation
Make get_working_dir reuse the working directory in bin/docker-to-squash.py - #9298
Closed
ToniAdreal wants to merge 1 commit into
Closed
ToniAdreal wants to merge 1 commit into
ToniAdreal wants to merge 1 commit into
Conversation
get_working_dir returned a different directory on every call: the requested directory the first time, a docker-to-squash subdirectory of it the second time, and on the third call os.makedirs raised FileExistsError, wrapped as 'Could not create working_dir'. pull-build calls it once per image, so the third image always failed, and push-update could not find the artifacts pull-build wrote. Create the directory with exist_ok=True and always return it. No caller depends on the subdirectory shape; all of them join paths under the returned directory. Signed-off-by: ToniAdreal <184365500+ToniAdreal@users.noreply.github.com>
Author
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.
Fixes #9292.
get_working_dirinbin/docker-to-squash.pyreturns a different directory on every call. Reproduced on Python 3.12.3 with an empty parent directory:dts-work-dirdts-work-dir/docker-to-squashException: Could not create working_dir: dts-work-dir/docker-to-squash, [Errno 17] File existspull-buildcalls it once per image, so the third image always fails, andpush-updatecannot find the artifactspull-buildwrote because it is working in a different directory.The fix creates the requested directory with
os.makedirs(directory, exist_ok=True)and always returns it. I checked the call sites before changing the shape: every caller (pull-build,push-update, and the other commands) only joins paths under the returned directory, none depends on thedocker-to-squashsubdirectory form. The error message on a genuine creation failure is unchanged apart from naming the requested directory.Testing: after the fix, three consecutive calls all return the requested directory and the directory exists. The existing suite also passes against this change (
python3 -m unittest test_docker_to_squash.py, run with the one-linecollections.abcimport shim from the #9291 PR in a scratch copy, since the suite cannot be imported on Python 3.10+ until that lands).This is one of the four docker-to-squash.py fixes #9284 left to separate PRs.