Skip to content

Commit

Permalink
create: do not hardcode imageName to DefaultInfraImage
Browse files Browse the repository at this point in the history
otherwise the setting in the containers.conf file is not honored.

Closes: containers#12245

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Nov 10, 2021
1 parent 5437568 commit 4bf9a51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
3 changes: 1 addition & 2 deletions cmd/podman/pods/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
28 changes: 28 additions & 0 deletions test/e2e/pod_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 4bf9a51

Please sign in to comment.