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

Fix podman pod inspect show wrong StaticMAC #8386

Merged
Merged
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
2 changes: 1 addition & 1 deletion libpod/define/pod_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type InspectPodInfraConfig struct {
StaticIP net.IP
// StaticMAC is a static MAC address that will be assigned to the infra
// container and then used by the pod.
StaticMAC net.HardwareAddr
StaticMAC string
// NoManageResolvConf indicates that the pod will not manage resolv.conf
// and instead each container will handle their own.
NoManageResolvConf bool
Expand Down
2 changes: 1 addition & 1 deletion libpod/pod_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
infraConfig = new(define.InspectPodInfraConfig)
infraConfig.HostNetwork = p.config.InfraContainer.HostNetwork
infraConfig.StaticIP = p.config.InfraContainer.StaticIP
infraConfig.StaticMAC = p.config.InfraContainer.StaticMAC
infraConfig.StaticMAC = p.config.InfraContainer.StaticMAC.String()
infraConfig.NoManageResolvConf = p.config.InfraContainer.UseImageResolvConf
infraConfig.NoManageHosts = p.config.InfraContainer.UseImageHosts

Expand Down
19 changes: 19 additions & 0 deletions test/e2e/pod_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,23 @@ var _ = Describe("Podman pod inspect", func() {
Expect(len(inspectJSON.InfraConfig.PortBindings["80/tcp"])).To(Equal(1))
Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0].HostPort).To(Equal("8080"))
})

It("podman pod inspect outputs show correct MAC", func() {
SkipIfRootless("--mac-address is not supported in rootless mode")
podName := "testPod"
macAddr := "42:43:44:00:00:01"
create := podmanTest.Podman([]string{"pod", "create", "--name", podName, "--mac-address", macAddr})
create.WaitWithDefaultTimeout()
Expect(create.ExitCode()).To(Equal(0))

create = podmanTest.Podman([]string{"run", "-d", "--pod", podName, ALPINE, "top"})
create.WaitWithDefaultTimeout()
Expect(create.ExitCode()).To(Equal(0))

inspectOut := podmanTest.Podman([]string{"pod", "inspect", podName})
inspectOut.WaitWithDefaultTimeout()
Expect(inspectOut.ExitCode()).To(Equal(0))

Expect(inspectOut.OutputToString()).To(ContainSubstring(macAddr))
})
})