Merge pull request #27028 from mfanjie/fix_cluster_sync_loop

Automatic merge from submit-queue

federation service controller: fixing a bug so that existing services are created in newly registered clusters

A defect on federation service controller.
Steps to recreate:
1. boot federation control plane
2. create a service and then register a new cluster

Root cause:
the right sequence should be  
```
servicesToUpdate = s.serviceCache.allServices()
```
then
```
s.updateAllServicesToCluster(servicesToUpdate, newCluster) 
```
then
```
servicesToUpdate = s.updateDNSRecords(servicesToUpdate, newClusters)
```
Now the first two lines' sequence is on the contrary, so when updateDNSRecords return no error, the service will be removed from  servicesToUpdate, and updateAllServicesToCluster get nothing to update.

This PR make the call sequence correct.

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
pull/6/head
k8s-merge-robot 2016-06-10 22:12:16 -07:00 committed by GitHub
commit 3cc43eb0d2
1 changed files with 6 additions and 6 deletions

View File

@ -235,7 +235,7 @@ func (s *ServiceController) Run(workers int, stopCh <-chan struct{}) error {
}
go wait.Until(s.clusterEndpointWorker, time.Second, stopCh)
go wait.Until(s.clusterServiceWorker, time.Second, stopCh)
go wait.Until(s.clusterSyncLoop, clusterSyncPeriod, stopCh)
go wait.Until(s.clusterSyncLoop, time.Second, stopCh)
<-stopCh
glog.Infof("Shutting down Federation Service Controller")
s.queue.ShutDown()
@ -619,14 +619,14 @@ func (s *ServiceController) clusterSyncLoop() {
increase = newSet.Difference(s.knownClusterSet)
// do nothing when cluster is removed.
if increase != nil {
for newCluster := range increase {
glog.Infof("New cluster observed %s", newCluster)
s.updateAllServicesToCluster(servicesToUpdate, newCluster)
}
// Try updating all services, and save the ones that fail to try again next
// round.
servicesToUpdate = s.serviceCache.allServices()
numServices := len(servicesToUpdate)
for newCluster := range increase {
glog.Infof("New cluster observed %s", newCluster)
s.updateAllServicesToCluster(servicesToUpdate, newCluster)
}
servicesToUpdate = s.updateDNSRecords(servicesToUpdate, newClusters)
glog.Infof("Successfully updated %d out of %d DNS records to direct traffic to the updated cluster",
numServices-len(servicesToUpdate), numServices)
@ -638,7 +638,7 @@ func (s *ServiceController) updateAllServicesToCluster(services []*cachedService
cluster, ok := s.clusterCache.clientMap[clusterName]
if ok {
for _, cachedService := range services {
appliedState := cachedService.appliedState
appliedState := cachedService.lastState
s.processServiceForCluster(cachedService, clusterName, appliedState, cluster.clientset)
}
}