From 4e63f9192dcdd4ee77732c320b237e9421072a73 Mon Sep 17 00:00:00 2001 From: wangqiang Date: Wed, 1 Dec 2021 21:03:25 +0800 Subject: Hostname in `spec.hostname` should be passed to infra ctr init opt Fixes https://github.com/containers/podman/issues/12393 Signed-off-by: Qiang Wang --- pkg/domain/infra/abi/play.go | 1 + test/e2e/play_kube_test.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index bdf22cf0c..ed70078b2 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -287,6 +287,7 @@ func (ic *ContainerEngine) playKubePod(ctx context.Context, podName string, podY if podOpt.Infra { infraImage := util.DefaultContainerConfig().Engine.InfraImage infraOptions := entities.NewInfraContainerCreateOptions() + infraOptions.Hostname = podSpec.PodSpecGen.PodBasicConfig.Hostname podSpec.PodSpecGen.InfraImage = infraImage podSpec.PodSpecGen.NoInfra = false podSpec.PodSpecGen.InfraContainerSpec = specgen.NewSpecGenerator(infraImage, false) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index fc939711f..1e15b50a7 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -1762,6 +1762,11 @@ var _ = Describe("Podman play kube", func() { inspect.WaitWithDefaultTimeout() Expect(inspect).Should(Exit(0)) Expect(inspect.OutputToString()).To(Equal(hostname)) + + hostnameInCtr := podmanTest.Podman([]string{"exec", getCtrNameInPod(pod), "hostname"}) + hostnameInCtr.WaitWithDefaultTimeout() + Expect(hostnameInCtr).Should(Exit(0)) + Expect(hostnameInCtr.OutputToString()).To(Equal(hostname)) }) It("podman play kube test HostAliases", func() { -- cgit v1.2.3-54-g00ecf