From 4bf9a51054fe56a4b07abf7421997c42ae5256a1 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Wed, 10 Nov 2021 10:44:45 +0100 Subject: [PATCH] create: do not hardcode imageName to DefaultInfraImage otherwise the setting in the containers.conf file is not honored. Closes: https://github.com/containers/podman/issues/12245 Signed-off-by: Giuseppe Scrivano --- cmd/podman/pods/create.go | 3 +-- test/e2e/pod_create_test.go | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go index b966706b4e..18b624689f 100644 --- a/cmd/podman/pods/create.go +++ b/cmd/podman/pods/create.go @@ -11,7 +11,6 @@ import ( "strings" "github.com/containers/common/pkg/completion" - "github.com/containers/common/pkg/config" "github.com/containers/common/pkg/sysinfo" "github.com/containers/podman/v3/cmd/podman/common" "github.com/containers/podman/v3/cmd/podman/containers" @@ -110,7 +109,7 @@ func create(cmd *cobra.Command, args []string) error { return errors.Wrapf(err, "unable to process labels") } - imageName = config.DefaultInfraImage + imageName = "" img := imageName if !createOptions.Infra { if cmd.Flag("no-hosts").Changed { diff --git a/test/e2e/pod_create_test.go b/test/e2e/pod_create_test.go index 12aeffd1b2..c356e84e39 100644 --- a/test/e2e/pod_create_test.go +++ b/test/e2e/pod_create_test.go @@ -957,6 +957,34 @@ ENTRYPOINT ["sleep","99999"] Expect(ctr3.OutputToString()).To(ContainSubstring("hello")) }) + It("podman pod create should use customized infra_image", func() { + conffile := filepath.Join(podmanTest.TempDir, "container.conf") + + infraImage := "k8s.gcr.io/pause:3.2" + err := ioutil.WriteFile(conffile, []byte(fmt.Sprintf("[engine]\ninfra_image=\"%s\"\n", infraImage)), 0644) + Expect(err).To(BeNil()) + + os.Setenv("CONTAINERS_CONF", conffile) + defer os.Unsetenv("CONTAINERS_CONF") + + if IsRemote() { + podmanTest.RestartRemoteService() + } + + cmd := podmanTest.Podman([]string{"pod", "create", "--name=check-pod-customized-image"}) + cmd.WaitWithDefaultTimeout() + Expect(cmd).Should(Exit(0)) + + podInspect := podmanTest.Podman([]string{"inspect", "check-pod-customized-image", "--format", "{{ .InfraContainerID }}"}) + podInspect.WaitWithDefaultTimeout() + infraContainerID := podInspect.OutputToString() + + conInspect := podmanTest.Podman([]string{"inspect", infraContainerID, "--format", "{{ .ImageName }}"}) + conInspect.WaitWithDefaultTimeout() + infraContainerImage := conInspect.OutputToString() + Expect(infraContainerImage).To(Equal(infraImage)) + }) + It("podman pod create read network mode from config", func() { confPath, err := filepath.Abs("config/containers-netns.conf") Expect(err).ToNot(HaveOccurred())