Skip to content

Make get_working_dir reuse the working directory in bin/docker-to-squash.py - #9298

Closed
ToniAdreal wants to merge 1 commit into
apache:masterfrom
ToniAdreal:fix-9292-get-working-dir
Closed

ToniAdreal wants to merge 1 commit into
apache:masterfrom
ToniAdreal:fix-9292-get-working-dir

Conversation

@ToniAdreal

Copy link
Copy Markdown

Fixes #9292.

get_working_dir in bin/docker-to-squash.py returns a different directory on every call. Reproduced on Python 3.12.3 with an empty parent directory:

  • 1st call -> dts-work-dir
  • 2nd call -> dts-work-dir/docker-to-squash
  • 3rd call -> raises Exception: Could not create working_dir: dts-work-dir/docker-to-squash, [Errno 17] File exists

pull-build calls it once per image, so the third image always fails, and push-update cannot find the artifacts pull-build wrote 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 the docker-to-squash subdirectory 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-line collections.abc import 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.

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>
@ToniAdreal

Copy link
Copy Markdown
Author

Closing this as a duplicate. @linzch3 already opened #9295 for #9292 two days ago, covering the same get_working_dir fix. I only spotted it after opening this one, sorry for the noise.

@ToniAdreal ToniAdreal closed this Nov 22, 2026
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.

docker-to-squash.py: get_working_dir creates a new directory on every call, so push-update cannot find pulled images

1 participant