Commit 3cc43eb0 authored by k8s-merge-robot's avatar k8s-merge-robot Committed by GitHub

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)]()
parents ede661b4 640d7dc7
...@@ -235,7 +235,7 @@ func (s *ServiceController) Run(workers int, stopCh <-chan struct{}) error { ...@@ -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.clusterEndpointWorker, time.Second, stopCh)
go wait.Until(s.clusterServiceWorker, 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 <-stopCh
glog.Infof("Shutting down Federation Service Controller") glog.Infof("Shutting down Federation Service Controller")
s.queue.ShutDown() s.queue.ShutDown()
...@@ -619,14 +619,14 @@ func (s *ServiceController) clusterSyncLoop() { ...@@ -619,14 +619,14 @@ func (s *ServiceController) clusterSyncLoop() {
increase = newSet.Difference(s.knownClusterSet) increase = newSet.Difference(s.knownClusterSet)
// do nothing when cluster is removed. // do nothing when cluster is removed.
if increase != nil { 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 // Try updating all services, and save the ones that fail to try again next
// round. // round.
servicesToUpdate = s.serviceCache.allServices() servicesToUpdate = s.serviceCache.allServices()
numServices := len(servicesToUpdate) numServices := len(servicesToUpdate)
for newCluster := range increase {
glog.Infof("New cluster observed %s", newCluster)
s.updateAllServicesToCluster(servicesToUpdate, newCluster)
}
servicesToUpdate = s.updateDNSRecords(servicesToUpdate, newClusters) servicesToUpdate = s.updateDNSRecords(servicesToUpdate, newClusters)
glog.Infof("Successfully updated %d out of %d DNS records to direct traffic to the updated cluster", glog.Infof("Successfully updated %d out of %d DNS records to direct traffic to the updated cluster",
numServices-len(servicesToUpdate), numServices) numServices-len(servicesToUpdate), numServices)
...@@ -638,7 +638,7 @@ func (s *ServiceController) updateAllServicesToCluster(services []*cachedService ...@@ -638,7 +638,7 @@ func (s *ServiceController) updateAllServicesToCluster(services []*cachedService
cluster, ok := s.clusterCache.clientMap[clusterName] cluster, ok := s.clusterCache.clientMap[clusterName]
if ok { if ok {
for _, cachedService := range services { for _, cachedService := range services {
appliedState := cachedService.appliedState appliedState := cachedService.lastState
s.processServiceForCluster(cachedService, clusterName, appliedState, cluster.clientset) s.processServiceForCluster(cachedService, clusterName, appliedState, cluster.clientset)
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment