Skip to content

Ignore .containerignore for git repositories in ADD#6800

Merged
TomSweeneyRedHat merged 1 commit into
containers:mainfrom
simonbrauner:issue-6614
May 19, 2026
Merged

Ignore .containerignore for git repositories in ADD#6800
TomSweeneyRedHat merged 1 commit into
containers:mainfrom
simonbrauner:issue-6614

Conversation

@simonbrauner
Copy link
Copy Markdown

@simonbrauner simonbrauner commented Apr 21, 2026

What type of PR is this?

/kind api-change

/kind bug

/kind cleanup
/kind deprecation
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake
/kind other

What this PR does / why we need it:

How to verify it

Which issue(s) this PR fixes:

Fixes: #6614

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Local `.containerignore` is no longer applied to ADD from git repositories.

@simonbrauner simonbrauner force-pushed the issue-6614 branch 4 times, most recently from ac2f35b to 9ae4022 Compare April 22, 2026 14:51
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

1 similar comment
@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@simonbrauner simonbrauner marked this pull request as ready for review April 22, 2026 16:24
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Apr 22, 2026
Comment thread docs/buildah-build.1.md Outdated
Copy link
Copy Markdown
Member

@Honny1 Honny1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, once @TomSweeneyRedHat 's comment is addressed.

Copy link
Copy Markdown
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stageExecutor.performCopy() method sets the "Excludes" field in the options and passes the list of sources to the Add() method. Can't it base the "Excludes" value it passes in on whether or not a source value it's also passing in is a git location?

If need be, the sourceIsGit() helper function could be moved from add.go to an internal package so that performCopy() could call it. There's a check early on in define.TempDirForURL() that could probably stand to use it, too.

Comment thread tests/bud.bats Outdated
Comment thread tests/bud.bats
@simonbrauner
Copy link
Copy Markdown
Author

@nalind thanks for the review

The stageExecutor.performCopy() method sets the "Excludes" field in the options and passes the list of sources to the Add() method. Can't it base the "Excludes" value it passes in on whether or not a source value it's also passing in is a git location?

If need be, the sourceIsGit() helper function could be moved from add.go to an internal package so that performCopy() could call it. There's a check early on in define.TempDirForURL() that could probably stand to use it, too.

Can you elaborate on this? If I understand this correctly, the idea is to set excludes correctly based on what the source is instead of having two - excludes and gitExcludes, and deciding which one is used later. I am fine with moving sourceIsGit elsewhere so that I can use it in the function that calls Add(), but I am not sure how to use sourceIsGit afterwards.

Because with my understanding:

The Add() method goes through all the sources at once, so there could be both git and non-git sources, so I cannot have one excludes.

Unless:

  1. I call Add() for each source separately. Which seems like a strange idea, given that Add() is implemented to handle all the sources at once.
  2. I call Add() twice; once for git sources and once for non-git sources. Which could be problematic when ordering matters in case there is ADD local git local git /mount-dir.

@nalind
Copy link
Copy Markdown
Member

nalind commented May 6, 2026

2. I call `Add()` twice; once for git sources and once for non-git sources. Which could be problematic when ordering matters in case there is `ADD local git local git /mount-dir`.

That's what we more or less already do when heredocs are also in the mix, so that wouldn't be a new problem.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 13, 2026
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels May 13, 2026
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 13, 2026
@simonbrauner
Copy link
Copy Markdown
Author

simonbrauner commented May 13, 2026

2. I call `Add()` twice; once for git sources and once for non-git sources. Which could be problematic when ordering matters in case there is `ADD local git local git /mount-dir`.

That's what we more or less already do when heredocs are also in the mix, so that wouldn't be a new problem.

@nalind I changed it in a way that git/nonGit is solved in stage_executor.go. Your comment should be addressed. There is the previous version for reference main...simonbrauner:buildah:issue-6614-v2.

@nalind
Copy link
Copy Markdown
Member

nalind commented May 13, 2026

@lsm5 I'm looking at https://artifacts.dev.testing-farm.io/f0d946c9-14ad-4e52-a385-49a751a8d7f6/ and can't reproduce that test failure in a Raw Hide VM with the rhcontainerbot/podman-next COPR enabled. Are the audit logs from the test somewhere that I couldn't spot?

Copy link
Copy Markdown
Member

@nalind nalind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nalind I changed it in a way that git/nonGit is solved in stage_executor.go. Your comment should be addressed. There is the previous version for reference main...simonbrauner:buildah:issue-6614-v2.

Great! LGTM

@lsm5
Copy link
Copy Markdown
Member

lsm5 commented May 13, 2026

@lsm5 I'm looking at https://artifacts.dev.testing-farm.io/f0d946c9-14ad-4e52-a385-49a751a8d7f6/ and can't reproduce that test failure in a Raw Hide VM with the rhcontainerbot/podman-next COPR enabled.

Just to make sure, you did not install buildah from podman-next but only the other deps, correct? podman-next packages have a super-high Epoch so if you didn't --exclude buildah while installing from podman-next, it'll very likely use buildah from podman-next which imo is not the one you want here.

Are the audit logs from the test somewhere that I couldn't spot?

Are you looking for avc denials? I don't think testing-farm/tmt setup captures them by default, but I'll ask around.

@lsm5
Copy link
Copy Markdown
Member

lsm5 commented May 13, 2026

Are the audit logs from the test somewhere that I couldn't spot?

I've filed a support ticket with testing-farm people

@nalind
Copy link
Copy Markdown
Member

nalind commented May 13, 2026

@lsm5 I'm looking at https://artifacts.dev.testing-farm.io/f0d946c9-14ad-4e52-a385-49a751a8d7f6/ and can't reproduce that test failure in a Raw Hide VM with the rhcontainerbot/podman-next COPR enabled.

Just to make sure, you did not install buildah from podman-next but only the other deps, correct? podman-next packages have a super-high Epoch so if you didn't --exclude buildah while installing from podman-next, it'll very likely use buildah from podman-next which imo is not the one you want here.

Updated to versions from the COPR, checked out this PR, built it, ran the in-tree versions of the tests. Also symlinked my tree's "bin" directory into /usr/share/buildah/test and ran the copy from /usr/share/buildah/test/system/ provided by the COPR's buildah-tests package. make forces the label type on the built copy to container_runtime_exec_t, which is the same one we apply to the version in /usr/bin.

Are the audit logs from the test somewhere that I couldn't spot?

Are you looking for avc denials? I don't think testing-farm/tmt setup captures them by default, but I'll ask around.

Yes. The tests are run as root, right? I do get the same error if I remove /usr/bin/selinuxenabled (by removing libselinux-utils), which the test uses to determine if $zflag needs to be set to "z" or left empty.

Fixes: containers#6614

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
@nalind
Copy link
Copy Markdown
Member

nalind commented May 19, 2026

@containers/buildah-maintainers PTAL

Copy link
Copy Markdown
Member

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@TomSweeneyRedHat
Copy link
Copy Markdown
Member

/lgtm

@TomSweeneyRedHat TomSweeneyRedHat merged commit 85f85a2 into containers:main May 19, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.dockerignore removes files from ADD git source

5 participants