-
Notifications
You must be signed in to change notification settings - Fork 802
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
Add --no-hostname option to buildah containers #5094
Conversation
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.
Mostly nits.
run_linux.go
Outdated
@@ -269,8 +269,7 @@ func (b *Builder) Run(command []string, options RunOptions) error { | |||
bindFiles[config.DefaultHostsFile] = hostFile | |||
} | |||
|
|||
// generate /etc/hostname if the user intentionally did not override | |||
if !(contains(volumes, "/etc/hostname")) { | |||
if !options.NoHostname && !(contains(volumes, "/etc/hostname")) { | |||
if _, ok := bindFiles["/etc/hostname"]; !ok { |
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 don't see how ok
can ever be true here. Did I miss something?
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 think this is for the use case where a user does -v /tmp/hostname:/etc/hostname
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 still don't follow. If I'm reading it right, the bindFiles
map has, at most, one item in it: a value for the config.DefaultHostsFile
key. A -v
flag from the command line would show up in options.Volumes
or b.CommonBuildOpts.Volumes
, or maybe both if we're in build
.
contains()
probably shouldn't exist when we got rid of for github.com/containers/buildah/util.StringInSlice()
in favor of github.com/containers/common/pkg/util.StringInSlice()
.
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.
That was existing code, so I will remove the check.
cmd/buildah/run.go
Outdated
@@ -137,10 +139,15 @@ func runCmd(c *cobra.Command, args []string, iopts runInputOptions) error { | |||
} | |||
} | |||
|
|||
if len(iopts.hostname) > 0 && iopts.noHostname { | |||
return errors.New("--no-hostname and --hostname conflict, can not be used together") |
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.
One's a setting in the UTS namespace, the other's a file. Do they conflict?
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 believe --hostname attempts to set the hostname field in /etc/hostname, if you don't think this would confuse the user, then I am fine with removing it.
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'd remove the test
tests/bud.bats
Outdated
cat > $mytmpdir/Containerfile << _EOF | ||
from alpine | ||
RUN mv /etc /usr/ | ||
RUN ls -l /etc |
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 content of this file will always be the same. Why are we generating it every time this test runs?
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.
This file has different content then the previous?
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.
Use two static files?
docs/buildah-build.1.md
Outdated
|
||
By default, Buildah manages _/etc/hostname_, adding the container's own hostname. | ||
**--no-hostname** disables this, and the image's _/etc/hostname_ will be preserved unmodified if it exists. | ||
Conflicts with the --hostname option. |
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 you remove the test above, you should remove this line too.
docs/buildah-build.1.md
Outdated
@@ -645,9 +645,17 @@ Valid _mode_ values are: | |||
|
|||
Do not use existing cached images for the container build. Build from the start with a new set of cached layers. | |||
|
|||
**--no-hostname** | |||
|
|||
Do not create _/etc/hostname_ for RUN instructions. |
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.
Soft suggestion
Do not create _/etc/hostname_ for RUN instructions. | |
Do not create the _/etc/hostname_ file in the container for RUN instructions. |
docs/buildah-build.1.md
Outdated
|
||
Do not create _/etc/hostname_ for RUN instructions. | ||
|
||
By default, Buildah manages _/etc/hostname_, adding the container's own hostname. |
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'm on the fence about adding the word file
after /etc/hostname here and below.
9d95258
to
c6ffdc7
Compare
LGTM @rhatdan I think it needs a rebase though |
LGTM |
Fixes: containers#5093 Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
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.
Restarted flaking test
LGTM
/lgtm
/hold
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: flouthoc, rhatdan 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 |
/unhold |
Reminder to also open Podman PRs when adding new build flags. Currently, Podman CI breaks when vendoring Buildah. |
Fixes: #5093
What type of PR is this?
What this PR does / why we need it:
How to verify it
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?