Merge pull request #22044 from davidopp/wait

Auto commit by PR queue bot
This commit is contained in:
k8s-merge-robot 2016-02-26 10:33:15 -08:00
commit cab55f856b

View File

@ -75,6 +75,7 @@ func (rc *RouteController) reconcile(nodes []api.Node, routes []*cloudprovider.R
for _, route := range routes { for _, route := range routes {
routeMap[route.TargetInstance] = route routeMap[route.TargetInstance] = route
} }
wg := sync.WaitGroup{}
for _, node := range nodes { for _, node := range nodes {
// Skip if the node hasn't been assigned a CIDR yet. // Skip if the node hasn't been assigned a CIDR yet.
if node.Spec.PodCIDR == "" { if node.Spec.PodCIDR == "" {
@ -89,15 +90,17 @@ func (rc *RouteController) reconcile(nodes []api.Node, routes []*cloudprovider.R
DestinationCIDR: node.Spec.PodCIDR, DestinationCIDR: node.Spec.PodCIDR,
} }
nameHint := string(node.UID) nameHint := string(node.UID)
wg.Add(1)
go func(nameHint string, route *cloudprovider.Route) { go func(nameHint string, route *cloudprovider.Route) {
if err := rc.routes.CreateRoute(rc.clusterName, nameHint, route); err != nil { if err := rc.routes.CreateRoute(rc.clusterName, nameHint, route); err != nil {
glog.Errorf("Could not create route %s %s: %v", nameHint, route.DestinationCIDR, err) glog.Errorf("Could not create route %s %s: %v", nameHint, route.DestinationCIDR, err)
} }
wg.Done()
}(nameHint, route) }(nameHint, route)
} }
nodeCIDRs[node.Name] = node.Spec.PodCIDR nodeCIDRs[node.Name] = node.Spec.PodCIDR
} }
wg := sync.WaitGroup{} wg.Wait()
for _, route := range routes { for _, route := range routes {
if rc.isResponsibleForRoute(route) { if rc.isResponsibleForRoute(route) {
// Check if this route applies to a node we know about & has correct CIDR. // Check if this route applies to a node we know about & has correct CIDR.