Skip to content
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

[WIP] Return slirp ip information from getHosts() #13219

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2377,7 +2377,17 @@ func (c *Container) getHosts() string {

if depCtr != nil {
host := ""
if depCtr.config.NetMode.IsSlirp4netns() {
// When using slirp4netns, the interface gets a static IP
if slirp4netnsIP, err := GetSlirp4netnsIP(depCtr.slirp4netnsSubnet); err != nil {
logrus.Warnf("Failed to determine slirp4netnsIP: %v", err.Error())
} else {
return fmt.Sprintf("%s\t%s %s\n", slirp4netnsIP.String(), c.Hostname(), c.config.Name)
}
}
Comment on lines +2380 to +2387
Copy link
Member

Choose a reason for hiding this comment

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

This block has to be moved to line 2318, you are changing the host.containers.internal code here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not find the depCtr until now.

outer:
// Paul this is returning nothing, even though I know depctr is up and
// running with an IP Address in rootfull mode?
Copy link
Member

Choose a reason for hiding this comment

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

I think you want to change c.cniHosts() and not the code here

Copy link
Member Author

Choose a reason for hiding this comment

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

Fine, how do I change it. It looks like depctr has no network in rootfull mode.

Copy link
Member

Choose a reason for hiding this comment

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

seems to work for me, what are you expecting?
This code is for host.containers.internal, if you want to add the container/host names you need to do this at a different place before this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Where would you suggest?

for net, status := range depCtr.getNetworkStatus() {
network, err := c.runtime.network.NetworkInspect(net)
// only add the host entry for bridge networks
Expand Down
1 change: 1 addition & 0 deletions libpod/networking_linux.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build linux
// +build linux

package libpod
Expand Down
1 change: 1 addition & 0 deletions test/e2e/run_networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ EXPOSE 2004-2005/tcp`, ALPINE)
exec4.WaitWithDefaultTimeout()
Expect(exec4).Should(Exit(0))
Expect(exec4.OutputToString()).To(ContainSubstring("192.0.2.2 test1"))
Expect(exec4.OutputToString()).To(ContainSubstring(ctrName2))
})

It("podman run /etc/hosts contains --hostname", func() {
Expand Down