sdn: wait for kubelet network plugin init before processing pods
We need the kubelet network Host object before we can update pods, so
wait for it.
@@ -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,6 +205,7 @@ 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
@@ -211,6 +214,10 @@ func (node *OsdnNode) Start() error {
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
pods, err = node.GetLocalPods(kapi.NamespaceAll)
@@ -226,6 +233,7 @@ func (node *OsdnNode) Start() error {
}
}
+ log.V(5).Infof("openshift-sdn network plugin ready")
node.markPodNetworkReady()
return nil
