summaryrefslogtreecommitdiff
path: root/pkg/specgen/generate
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-11-30 19:41:26 +0100
committerGitHub <noreply@github.com>2020-11-30 19:41:26 +0100
commitf24812ac3ba969bc5a0628b819699d747c853e36 (patch)
tree8fb9008547faab653f14e07dd4f380b325874c06 /pkg/specgen/generate
parent9f2c8f267e22897719ee8c3a15202afeaedda547 (diff)
parenta4da384b559796ecbf49746e655876138d494864 (diff)
downloadpodman-f24812ac3ba969bc5a0628b819699d747c853e36.tar.gz
podman-f24812ac3ba969bc5a0628b819699d747c853e36.tar.bz2
podman-f24812ac3ba969bc5a0628b819699d747c853e36.zip
Merge pull request #8230 from mheon/port_net_host_conflict
Ensure that --net=host/pod/container conflicts with -p
Diffstat (limited to 'pkg/specgen/generate')
-rw-r--r--pkg/specgen/generate/container.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/pkg/specgen/generate/container.go b/pkg/specgen/generate/container.go
index 2ee8f2441..c7e62d185 100644
--- a/pkg/specgen/generate/container.go
+++ b/pkg/specgen/generate/container.go
@@ -257,7 +257,19 @@ func CompleteSpec(ctx context.Context, r *libpod.Runtime, s *specgen.SpecGenerat
}
}
- return verifyContainerResources(s)
+ warnings, err := verifyContainerResources(s)
+ if err != nil {
+ return warnings, err
+ }
+
+ // Warn on net=host/container/pod/none and port mappings.
+ if (s.NetNS.NSMode == specgen.Host || s.NetNS.NSMode == specgen.FromContainer ||
+ s.NetNS.NSMode == specgen.FromPod || s.NetNS.NSMode == specgen.NoNetwork) &&
+ len(s.PortMappings) > 0 {
+ warnings = append(warnings, "Port mappings have been discarded as one of the Host, Container, Pod, and None network modes are in use")
+ }
+
+ return warnings, nil
}
// finishThrottleDevices takes the temporary representation of the throttle