summaryrefslogtreecommitdiff
path: root/pkg/specgen
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-08-21 18:52:55 +0200
committerGitHub <noreply@github.com>2020-08-21 18:52:55 +0200
commit4828455055010a1376f1e83832bfa34787f3a1e7 (patch)
tree5e74cd1f2800552042901173923d3f35386882ca /pkg/specgen
parenta8619bbb832646a816a138e0656ca6abdc9ad04e (diff)
parent7b21bcef5881db4f341090d255f6ef204a30dd1e (diff)
downloadpodman-4828455055010a1376f1e83832bfa34787f3a1e7.tar.gz
podman-4828455055010a1376f1e83832bfa34787f3a1e7.tar.bz2
podman-4828455055010a1376f1e83832bfa34787f3a1e7.zip
Merge pull request #7390 from baude/podnet
error when adding container to pod with network information
Diffstat (limited to 'pkg/specgen')
-rw-r--r--pkg/specgen/container_validate.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/specgen/container_validate.go b/pkg/specgen/container_validate.go
index 76961fa80..dc9e6b9d8 100644
--- a/pkg/specgen/container_validate.go
+++ b/pkg/specgen/container_validate.go
@@ -37,6 +37,23 @@ func (s *SpecGenerator) Validate() error {
}
}
+ // Containers being added to a pod cannot have certain network attributes
+ // associated with them because those should be on the infra container.
+ if len(s.Pod) > 0 && s.NetNS.NSMode == FromPod {
+ if s.StaticIP != nil || s.StaticIPv6 != nil {
+ return errors.Wrap(define.ErrNetworkOnPodContainer, "static ip addresses must be defined when the pod is created")
+ }
+ if s.StaticMAC != nil {
+ return errors.Wrap(define.ErrNetworkOnPodContainer, "MAC addresses must be defined when the pod is created")
+ }
+ if len(s.CNINetworks) > 0 {
+ return errors.Wrap(define.ErrNetworkOnPodContainer, "networks must be defined when the pod is created")
+ }
+ if len(s.PortMappings) > 0 || s.PublishExposedPorts {
+ return errors.Wrap(define.ErrNetworkOnPodContainer, "published or exposed ports must be defined when the pod is created")
+ }
+ }
+
//
// ContainerBasicConfig
//