mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
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 []()
This commit is contained in:
commit
c5afca10f4
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user