diff --git a/images/dind/dind-setup.sh b/images/dind/dind-setup.sh index addea721d4e6..ba082836a93a 100644 --- a/images/dind/dind-setup.sh +++ b/images/dind/dind-setup.sh @@ -42,4 +42,5 @@ function enable-overlay-storage() { } mount --make-shared / +mount --make-shared /run enable-overlay-storage diff --git a/pkg/sdn/plugin/cniserver/cniserver.go b/pkg/sdn/plugin/cniserver/cniserver.go index 2244e061dc82..df2c88ab16ea 100644 --- a/pkg/sdn/plugin/cniserver/cniserver.go +++ b/pkg/sdn/plugin/cniserver/cniserver.go @@ -12,6 +12,9 @@ import ( "github.com/golang/glog" "github.com/gorilla/mux" + + utilruntime "k8s.io/kubernetes/pkg/util/runtime" + utilwait "k8s.io/kubernetes/pkg/util/wait" ) // *** The CNIServer is PRIVATE API between OpenShift SDN components and may be @@ -141,7 +144,11 @@ func (s *CNIServer) Start(requestFunc cniRequestFunc) error { } s.SetKeepAlivesEnabled(false) - go s.Serve(l) + go utilwait.Forever(func() { + if err := s.Serve(l); err != nil { + utilruntime.HandleError(fmt.Errorf("CNI server Serve() failed: %v", err)) + } + }, 0) return nil } diff --git a/pkg/sdn/plugin/controller.go b/pkg/sdn/plugin/controller.go index aa7e51065ee3..2a8a36882924 100644 --- a/pkg/sdn/plugin/controller.go +++ b/pkg/sdn/plugin/controller.go @@ -90,7 +90,7 @@ func (plugin *OsdnNode) alreadySetUp(localSubnetGatewayCIDR, clusterNetworkCIDR } found = false for _, addr := range addrs { - if strings.Contains(addr, localSubnetGatewayCIDR+" ") { + if strings.Contains(addr, localSubnetGatewayCIDR) { found = true break } diff --git a/pkg/sdn/plugin/node.go b/pkg/sdn/plugin/node.go index 1585a7e0cfdb..3e9e0ae0759f 100644 --- a/pkg/sdn/plugin/node.go +++ b/pkg/sdn/plugin/node.go @@ -41,6 +41,7 @@ type OsdnNode struct { localIP string hostName string podNetworkReady chan struct{} + kubeletInitReady chan struct{} vnids *nodeVNIDMap iptablesSyncPeriod time.Duration mtu uint32 @@ -96,6 +97,7 @@ func NewNodePlugin(pluginName string, osClient *osclient.Client, kClient *kclien hostName: hostname, vnids: newNodeVNIDMap(), podNetworkReady: make(chan struct{}), + kubeletInitReady: make(chan struct{}), iptablesSyncPeriod: iptablesSyncPeriod, mtu: mtu, egressPolicies: make(map[uint32][]*osapi.EgressNetworkPolicy), @@ -203,10 +205,18 @@ func (node *OsdnNode) Start() error { } } + log.V(5).Infof("Creating and initializing openshift-sdn pod manager") node.podManager, err = newPodManager(node.host, node.multitenant, node.localSubnetCIDR, node.networkInfo, node.kClient, node.vnids, node.mtu) if err != nil { return err } + if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil { + return err + } + + // Wait for kubelet to init the plugin so we get a knetwork.Host + log.V(5).Infof("Waiting for kubelet network plugin initialization") + <-node.kubeletInitReady if networkChanged { var pods []kapi.Pod @@ -223,10 +233,7 @@ func (node *OsdnNode) Start() error { } } - if err := node.podManager.Start(cniserver.CNIServerSocketPath); err != nil { - return err - } - + log.V(5).Infof("openshift-sdn network plugin ready") node.markPodNetworkReady() return nil diff --git a/pkg/sdn/plugin/plugin.go b/pkg/sdn/plugin/plugin.go index 0b5836278584..0bf386d6e3dd 100644 --- a/pkg/sdn/plugin/plugin.go +++ b/pkg/sdn/plugin/plugin.go @@ -8,6 +8,8 @@ import ( knetwork "k8s.io/kubernetes/pkg/kubelet/network" kcni "k8s.io/kubernetes/pkg/kubelet/network/cni" utilsets "k8s.io/kubernetes/pkg/util/sets" + + "github.com/golang/glog" ) // This kubelet network plugin shim only exists to grab the knetwork.Host @@ -22,7 +24,13 @@ func (node *OsdnNode) Init(host knetwork.Host, hairpinMode componentconfig.Hairp node.host = host node.kubeletCniPlugin = plugins[0] - return node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu) + err := node.kubeletCniPlugin.Init(host, hairpinMode, nonMasqueradeCIDR, mtu) + + // Let initial pod updates happen if they need to + glog.V(5).Infof("openshift-sdn CNI plugin initialized") + close(node.kubeletInitReady) + + return err } func (node *OsdnNode) Name() string {