• 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
.github Loading commit data...
Godeps Loading commit data...
api Loading commit data...
build Loading commit data...
cluster Loading commit data...
cmd Loading commit data...
docs Loading commit data...
examples Loading commit data...
federation Loading commit data...
hack Loading commit data...
hooks Loading commit data...
logo Loading commit data...
pkg Loading commit data...
plugin Loading commit data...
staging Loading commit data...
test Loading commit data...
third_party Loading commit data...
translations Loading commit data...
vendor Loading commit data...
.bazelrc Loading commit data...
.gazelcfg.json Loading commit data...
.generated_files Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
BUILD.bazel Loading commit data...
CHANGELOG.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
Makefile Loading commit data...
Makefile.generated_files Loading commit data...
OWNERS Loading commit data...
OWNERS_ALIASES Loading commit data...
README.md Loading commit data...
Vagrantfile Loading commit data...
WORKSPACE Loading commit data...
code-of-conduct.md Loading commit data...
labels.yaml Loading commit data...