summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcdoern <cbdoer23@g.holycross.edu>2022-05-05 20:12:44 -0400
committercdoern <cdoern@redhat.com>2022-06-02 14:16:28 -0400
commit831d6534fb7b04e092710dfa5d233fe5cb9db9f8 (patch)
treef9a6a329c7bcd11f7480bce8b4771adae8e16555
parentbe527a358a7da7c6ea762da8836e39cfddd18297 (diff)
downloadpodman-831d6534fb7b04e092710dfa5d233fe5cb9db9f8.tar.gz
podman-831d6534fb7b04e092710dfa5d233fe5cb9db9f8.tar.bz2
podman-831d6534fb7b04e092710dfa5d233fe5cb9db9f8.zip
fix pod network handling with a host network
the function `GetDefaultNamespaceMode` for pods checks if we are sharing each namespace and if not, returns the default which in the case of a network is slirp. add a switch case for explicitly checking if the pod's network mode is host and if so, return specgen.Host for the container resolves #13763 Signed-off-by: cdoern <cbdoer23@g.holycross.edu> Signed-off-by: cdoern <cdoern@redhat.com>
-rw-r--r--pkg/specgen/generate/namespaces.go3
-rw-r--r--test/e2e/pod_infra_container_test.go13
2 files changed, 16 insertions, 0 deletions
diff --git a/pkg/specgen/generate/namespaces.go b/pkg/specgen/generate/namespaces.go
index 4dd6b3eaf..4735111c8 100644
--- a/pkg/specgen/generate/namespaces.go
+++ b/pkg/specgen/generate/namespaces.go
@@ -42,6 +42,9 @@ func GetDefaultNamespaceMode(nsType string, cfg *config.Config, pod *libpod.Pod)
podMode = true
case nsType == "net" && pod.SharesNet():
podMode = true
+ case nsType == "net" && pod.NetworkMode() == "host":
+ toReturn.NSMode = specgen.Host
+ return toReturn, nil
case nsType == "cgroup" && pod.SharesCgroup():
podMode = true
}
diff --git a/test/e2e/pod_infra_container_test.go b/test/e2e/pod_infra_container_test.go
index ab204992c..ad2db2411 100644
--- a/test/e2e/pod_infra_container_test.go
+++ b/test/e2e/pod_infra_container_test.go
@@ -125,6 +125,19 @@ var _ = Describe("Podman pod create", func() {
session = podmanTest.Podman([]string{"run", fedoraMinimal, "curl", "-f", "localhost"})
session.WaitWithDefaultTimeout()
Expect(session).To(ExitWithError())
+
+ session = podmanTest.Podman([]string{"pod", "create", "--network", "host"})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"run", "-dt", "--pod", session.OutputToString(), ALPINE})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+
+ session = podmanTest.Podman([]string{"inspect", "--format", "'{{.NetworkSettings.SandboxKey}}'", session.OutputToString()})
+ session.WaitWithDefaultTimeout()
+ Expect(session).Should(Exit(0))
+ Expect(session.OutputToString()).Should(ContainSubstring("''")) // no network path... host
})
It("podman pod correctly sets up IPCNS", func() {