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

create: do not hardcode imageName to DefaultInfraImage #12249

Closed
Closed
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
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 = ""
giuseppe marked this conversation as resolved.
Show resolved Hide resolved
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Shouldn't this come from the client?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since your PR deals with this better, let's close mine in favor of yours

}

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