Merge pull request from cdoern/infra

pod create --share none should not create infra
This commit is contained in:
OpenShift Merge Robot
2022-07-26 16:21:40 +02:00
committed by GitHub
3 changed files with 23 additions and 1 deletions
cmd/podman/pods
docs/source/markdown
test/e2e

@ -134,6 +134,12 @@ func create(cmd *cobra.Command, args []string) error {
imageName = infraImage imageName = infraImage
} }
img := imageName img := imageName
if !cmd.Flag("infra").Changed && (share == "none" || share == "") {
// we do not want an infra container when not sharing namespaces
createOptions.Infra = false
}
if !createOptions.Infra { if !createOptions.Infra {
if cmd.Flag("no-hosts").Changed { if cmd.Flag("no-hosts").Changed {
return fmt.Errorf("cannot specify --no-hosts without an infra container") return fmt.Errorf("cannot specify --no-hosts without an infra container")

@ -373,7 +373,7 @@ Note: Labeling can be disabled for all containers by setting label=false in the
#### **--share**=*namespace* #### **--share**=*namespace*
A comma-separated list of kernel namespaces to share. If none or "" is specified, no namespaces will be shared. The namespaces to choose from are cgroup, ipc, net, pid, uts. If the option is prefixed with a "+" then the namespace is appended to the default list, otherwise it replaces the default list. Defaults matches Kubernetes default (ipc, net, uts) A comma-separated list of kernel namespaces to share. If none or "" is specified, no namespaces will be shared and the infra container will not be created unless expiclity specified via **--infra=true**. The namespaces to choose from are cgroup, ipc, net, pid, uts. If the option is prefixed with a "+" then the namespace is appended to the default list, otherwise it replaces the default list. Defaults matches Kubernetes default (ipc, net, uts)
#### **--share-parent** #### **--share-parent**

@ -435,4 +435,20 @@ var _ = Describe("Podman pod create", func() {
Expect(session).Should(Exit(0)) Expect(session).Should(Exit(0))
Expect(session.OutputToString()).To(ContainSubstring(hostname)) Expect(session.OutputToString()).To(ContainSubstring(hostname))
}) })
tests := []string{"", "none"}
for _, test := range tests {
test := test
It("podman pod create --share="+test+" should not create an infra ctr", func() {
session := podmanTest.Podman([]string{"pod", "create", "--share", test})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
session = podmanTest.Podman([]string{"pod", "inspect", "--format", "{{.NumContainers}}", session.OutputToString()})
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
Expect(session.OutputToString()).Should((Equal("0")))
})
}
}) })