Merge pull request #2545 from haircommander/weird_pod_bug

Fix pod create failure
This commit is contained in:
OpenShift Merge Robot
2019-03-06 10:57:54 -08:00
committed by GitHub

View File

@ -95,9 +95,12 @@ func (r *Runtime) NewPod(ctx context.Context, options ...PodCreateOption) (*Pod,
if pod.config.UsePodCgroup { if pod.config.UsePodCgroup {
logrus.Debugf("Got pod cgroup as %s", pod.state.CgroupPath) logrus.Debugf("Got pod cgroup as %s", pod.state.CgroupPath)
} }
if pod.HasInfraContainer() != pod.SharesNamespaces() { if !pod.HasInfraContainer() && pod.SharesNamespaces() {
return nil, errors.Errorf("Pods must have an infra container to share namespaces") return nil, errors.Errorf("Pods must have an infra container to share namespaces")
} }
if pod.HasInfraContainer() && !pod.SharesNamespaces() {
logrus.Warnf("Pod has an infra container, but shares no namespaces")
}
if err := r.state.AddPod(pod); err != nil { if err := r.state.AddPod(pod); err != nil {
return nil, errors.Wrapf(err, "error adding pod to state") return nil, errors.Wrapf(err, "error adding pod to state")