-
Notifications
You must be signed in to change notification settings - Fork 2.7k
build: reuse parse.ContainerIgnoreFile
from buildah
#26216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cmd/podman/common/build.go
Outdated
@@ -585,7 +585,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil | |||
} | |||
|
|||
if flags.IgnoreFile != "" { | |||
excludes, err := parseDockerignore(flags.IgnoreFile) | |||
excludes, _, err := parse.ContainerIgnoreFile(contextDir, flags.IgnoreFile, containerFiles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function comment says
Deprecated since this might become internal only, please avoid relying on this function.
So what is the status with that, either we should not use it or change the buildah comment to actual commit to that as API? Personally I am all for such code sharing.
cc @nalind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We added notice here containers/buildah#4239 but at that time this function was not being used anywhere else, I think podman
has a use-case for this. I am wondering if we can remove the deprecation notice ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right I agree. Just pointing out that the buildah comment should then get updated if we start to depend on it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc, Luap99 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@containers/podman-maintainers PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the parser should be shared.
Right now, Buildah seems to me to be fairly uncertain about layering / responsibilities, and that leads to clearly unnecessary manipulation of containerFiles
here.
Can the whole problem space be cleaned up further, please?
- Maybe both Podman and Buildah should just pass the
IgnoreFile
option down to the executors, without parsing files at the CLI layer. (Purely aesthetically, I’d like that.) - Maybe buildah should export a special-case
ParseIgnoreFile
function that does not require the caller to providecontainerFiles
, and to only invoke the larger logic onContainerIgnoreFile
in some special situations (??). (Or invokeimagebuilder.ParseIgnore
directly without a Buildah re-export?) - Quite likely I’m underappreciating the complexity of the design and completely misinterpreting the larger situation.
cmd/podman/common/build.go
Outdated
@@ -585,7 +585,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *Buil | |||
} | |||
|
|||
if flags.IgnoreFile != "" { | |||
excludes, err := parseDockerignore(flags.IgnoreFile) | |||
excludes, _, err := parse.ContainerIgnoreFile(contextDir, flags.IgnoreFile, containerFiles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if flags.IgnoreFile != ""
, containerFiles
are not processed at all.
Meanwhile, imagebuildah.newExecutor
also calls ContainerIgnoreFile
, at that lower level.
I read BuildOptions.Excludes
vs. BuildOptions.IgnoreFile
to mean that it makes sense to only set one of the two. But buildah/pkg/cli.GenBuildOptions
(not called in Podman, to be fair) sets both (computing Excludes
from IgnoreFile
).
What is the intended layering / responsibility division between the CLI and the underlying build code? (More of a Buildah question, not a Podman question, sure.)
@mtrmac I think we need to do parsing of Irrespective of the above case I still think somethings can be fixed at buildah at first and then podman can start using it, do you think it will be okay to those changes in a new PR and scope this PR only to the bug fix above ? |
Thanks, so I was missing something.
What about those
The more comprehensive cleanup of Buildah (if that still makes sense) can be done later, that’s pre-existing; but adding extra complexity to Podman would be adding to tech debt and is fairly cheaply avoidable now, when we understand the situation. |
Looking a bit more closely, $contextDir is transferred to the remote, but if Hum… should the Or, maybe, keep the |
I did not understand this comment exactly. As per function
TLDR: It searches for ignorefiles in following order, then if found parses and returns list of excludes.
The function overall appears to me doing correctly and I did not understand why the use of |
Look at the current call site: it calls
The function is (to my limited knowledge) fine; the misleading part is that the caller passes |
[NON-BLOCKING] Packit jobs failed. @containers/packit-build please check. Everyone else, feel free to ignore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (but I’d really prefer a careful second review by someone more familiar with this).
podman's logic to parse excludes from `--ignorefile` is not consistent with buildah, use code directly from imagebuilder. Closes: containers#25746 Signed-off-by: flouthoc <flouthoc.git@gmail.com>
Okay it seems like I cannot just remove I have decided to use I will refactor things on buildah side and see if we can unify this part with buildah ( unrelated to this bug ). |
LGTM, that’s a clear local improvement. |
@containers/podman-maintainers PTAL |
/lgtm |
6a39f37
into
containers:main
podman's logic to parse excludes from
--ignorefile
is not consistent with buildah, use code directly from buildah.Closes: #25746
Does this PR introduce a user-facing change?