mirror of https://github.com/k3s-io/k3s
add kubernetes service back when it is deleted in kubernetes cluster
parent
fae7285b00
commit
669bf0773f
|
@ -68,7 +68,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 {
|
||||
|
@ -81,10 +81,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 {
|
||||
|
@ -108,6 +110,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