• Kubernetes Submit Queue's avatar
    Merge pull request #44379 from guangyouyu/garyyu_master · 7f0004de
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue
    
    Bugfix: cloud-controller-manager routeController.run() block in WaitForCacheSync
    
    **What this PR does / why we need it**:
    cloud-controller-manager routeController.run not run in goroutine will block to  wait nodeListerSynced because sharedInformers not started
    
    
    **Special notes for your reviewer**:
    
    cloud-controller-manager routeController.run  should run in goroutine like the same code in kube-controller-manager,or it will block to  wait nodeListerSynced,but sharedInformers not startd.
    
    ```go
    //controller-manager.go:197
    func StartControllers(s *options.CloudControllerManagerServer, kubeconfig *restclient.Config, rootClientBuilder, clientBuilder controller.ControllerClientBuilder, stop <-chan struct{}, recorder record.EventRecorder, cloud cloudprovider.Interface) error {
    	// Function to build the kube client object
    	client := func(serviceAccountName string) clientset.Interface {
    		return rootClientBuilder.ClientOrDie(serviceAccountName)
    	}
    	versionedClient := client("shared-informers")
    	sharedInformers := informers.NewSharedInformerFactory(versionedClient, resyncPeriod(s)())
    ocateNodeCIDRs && s.ConfigureCloudRoutes {
    		if routes, ok := cloud.Routes(); !ok {
    			glog.Warning("configure-cloud-routes is set, but cloud provider does not support routes. Will not configure cloud provider routes.")
    		} else {
    			routeController := routecontroller.New(routes, client("route-controller"), sharedInformers.Core().V1().Nodes(), s.ClusterName, clusterCIDR)
                           //should run in goroutine
    ----->		routeController.Run(stop, s.RouteReconciliationPeriod.Duration)
    			time.Sleep(wait.Jitter(s.ControllerStartInterval.Duration, ControllerStartJitter))
    		}
    	} else {
    		glog.Infof("Will not configure cloud provider routes for allocate-node-cidrs: %v, configure-cloud-routes: %v.", s.AllocateNodeCIDRs, s.ConfigureCloudRoutes)
    	}
    
    ---> 	sharedInformers.Start(stop)
    
    	select {}
    }
    
    
    
    //routecontroller.go:77
    func (rc *RouteController) Run(stopCh <-chan struct{}, syncPeriod time.Duration) {
    	defer utilruntime.HandleCrash()
    
    	glog.Info("Starting the route controller")
           //will block
    --->   	if !cache.WaitForCacheSync(stopCh, rc.nodeListerSynced) {
    		utilruntime.HandleError(fmt.Errorf("timed out waiting for caches to sync"))
    		return
    	}
    
    	go wait.NonSlidingUntil(func() {
    		if err := rc.reconcileNodeRoutes(); err != nil {
    			glog.Errorf("Couldn't reconcile node routes: %v", err)
    		}
    	}, syncPeriod, wait.NeverStop)
    }
    ```
    7f0004de
Name
Last commit
Last update
..
clicheck Loading commit data...
cloud-controller-manager Loading commit data...
gendocs Loading commit data...
genkubedocs Loading commit data...
genman Loading commit data...
genslateyaml Loading commit data...
genswaggertypedocs Loading commit data...
genutils Loading commit data...
genyaml Loading commit data...
gke-certificates-controller Loading commit data...
hyperkube Loading commit data...
kube-apiserver Loading commit data...
kube-controller-manager Loading commit data...
kube-proxy Loading commit data...
kubeadm Loading commit data...
kubectl Loading commit data...
kubelet Loading commit data...
kubemark Loading commit data...
libs/go2idl Loading commit data...
linkcheck Loading commit data...
mungedocs Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...