Merge pull request #27748 from mfanjie/service-controller

Automatic merge from submit-queue

Federation: Improve the handling of service deletion in underlying clusters

fixes #27623 

[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/.github/PULL_REQUEST_TEMPLATE.md?pixel)]()
This commit is contained in:
k8s-merge-robot 2016-06-22 16:21:16 -07:00 committed by GitHub
commit c5afca10f4

View File

@ -69,7 +69,7 @@ func (cc *clusterClientCache) syncService(key, clusterName string, clusterCache
clusterCache.serviceQueue.Add(key)
return err
}
var needUpdate bool
var needUpdate, isDeletion bool
if exists {
service, ok := serviceInterface.(*v1.Service)
if ok {
@ -82,10 +82,12 @@ func (cc *clusterClientCache) syncService(key, clusterName string, clusterCache
}
glog.Infof("Found tombstone for %v", key)
needUpdate = cc.processServiceDeletion(cachedService, clusterName)
isDeletion = true
}
} else {
glog.Infof("Can not get service %v for cluster %s from serviceStore", key, clusterName)
needUpdate = cc.processServiceDeletion(cachedService, clusterName)
isDeletion = true
}
if needUpdate {
@ -110,6 +112,15 @@ func (cc *clusterClientCache) syncService(key, clusterName string, clusterCache
}
}
}
if isDeletion {
// cachedService is not reliable here as
// deleting cache is the last step of federation service deletion
_, err := fedClient.Core().Services(cachedService.lastState.Namespace).Get(cachedService.lastState.Name)
// rebuild service if federation service still exists
if err == nil || !errors.IsNotFound(err) {
return sc.ensureClusterService(cachedService, clusterName, cachedService.appliedState, clusterCache.clientset)
}
}
return nil
}