mirror of
https://github.com/containers/podman.git
synced 2025-05-31 15:42:48 +08:00
Fix podman pod inspect show wrong MAC string
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
This commit is contained in:
@ -67,7 +67,7 @@ type InspectPodInfraConfig struct {
|
|||||||
StaticIP net.IP
|
StaticIP net.IP
|
||||||
// StaticMAC is a static MAC address that will be assigned to the infra
|
// StaticMAC is a static MAC address that will be assigned to the infra
|
||||||
// container and then used by the pod.
|
// container and then used by the pod.
|
||||||
StaticMAC net.HardwareAddr
|
StaticMAC string
|
||||||
// NoManageResolvConf indicates that the pod will not manage resolv.conf
|
// NoManageResolvConf indicates that the pod will not manage resolv.conf
|
||||||
// and instead each container will handle their own.
|
// and instead each container will handle their own.
|
||||||
NoManageResolvConf bool
|
NoManageResolvConf bool
|
||||||
|
@ -535,7 +535,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
|
|||||||
infraConfig = new(define.InspectPodInfraConfig)
|
infraConfig = new(define.InspectPodInfraConfig)
|
||||||
infraConfig.HostNetwork = p.config.InfraContainer.HostNetwork
|
infraConfig.HostNetwork = p.config.InfraContainer.HostNetwork
|
||||||
infraConfig.StaticIP = p.config.InfraContainer.StaticIP
|
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.NoManageResolvConf = p.config.InfraContainer.UseImageResolvConf
|
||||||
infraConfig.NoManageHosts = p.config.InfraContainer.UseImageHosts
|
infraConfig.NoManageHosts = p.config.InfraContainer.UseImageHosts
|
||||||
|
|
||||||
|
@ -99,4 +99,23 @@ var _ = Describe("Podman pod inspect", func() {
|
|||||||
Expect(len(inspectJSON.InfraConfig.PortBindings["80/tcp"])).To(Equal(1))
|
Expect(len(inspectJSON.InfraConfig.PortBindings["80/tcp"])).To(Equal(1))
|
||||||
Expect(inspectJSON.InfraConfig.PortBindings["80/tcp"][0].HostPort).To(Equal("8080"))
|
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))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user