buildah
buildah copied to clipboard
Fix conflict on heredoc temp files
What type of PR is this?
/kind bug
What this PR does / why we need it:
If two image builds start concurrently and they both use an heredoc with the same EOF marker, then they will use the same filename and overwrite each other.
It's possible for concurrent builds to either use the wrong heredoc content or to fail because the file of one build is deleted by the other, leading to this error message:
STEP 13/21: COPY <<EOF /file.conf
Error: building at STEP "COPY <<EOF /file.conf": reading "/var/tmp/EOF": copier: get: globs [/EOF] matched nothing (0 filtered out): no such file or directory
How to verify it
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?
I would like to add tests but I'm not familiar with the project, what would be the best place to add these ?
(I've tried adding to bud.bats but run_buildah doesn't seem ready to test concurrent operations.)
A friendly reminder that this PR had no activity for 30 days.
@edsantiago thoughts on tests ?
I see no reason for tests. However, @kmichel-aiven , could you please clean up your git commit, and rebase?
[APPROVALNOTIFIER] This PR is NOT APPROVED
This pull-request has been approved by: kmichel-aiven Once this PR has been reviewed and has the lgtm label, please assign tomsweeneyredhat for approval. For more information see the Kubernetes Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
@flouthoc if you get a minute to look at this one, I'd appreciate it.
This isn't going to work as intended when the destination for a COPY with a heredoc is a directory - the destination file's name should be the same as the delimiter, and os.CreateTemp() will create a file with a name that has a suffix added to ensure that it's unique. If it used os.MkdirTemp(), and placed the file in the resulting directory (deferring removal of the directory as well as the file), I think it would work as intended.
~The "bud build with heredoc content" integration test should suffice to catch that, so I'll add the no-new-tests-needed label so that it can be run.~
This isn't going to work as intended when the destination for a COPY with a heredoc is a directory - the destination file's name should be the same as the delimiter, and
os.CreateTemp()will create a file with a name that has a suffix added to ensure that it's unique. If it usedos.MkdirTemp(), and placed the file in the resulting directory (deferring removal of the directory as well as the file), I think it would work as intended. ~The "bud build with heredoc content" integration test should suffice to catch that, so I'll add the no-new-tests-needed label so that it can be run.~
@kmichel-aiven Could you please do the changes as suggested above. So we can move ahead with this PR.
A friendly reminder that this PR had no activity for 30 days.
Obsoleted by https://github.com/containers/buildah/pull/5959, closing.