add kubernetes service back when it is deleted in kubernetes cluster
This commit is contained in:
		@@ -68,7 +68,7 @@ func (cc *clusterClientCache) syncService(key, clusterName string, clusterCache
 | 
				
			|||||||
		clusterCache.serviceQueue.Add(key)
 | 
							clusterCache.serviceQueue.Add(key)
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var needUpdate bool
 | 
						var needUpdate, isDeletion bool
 | 
				
			||||||
	if exists {
 | 
						if exists {
 | 
				
			||||||
		service, ok := serviceInterface.(*v1.Service)
 | 
							service, ok := serviceInterface.(*v1.Service)
 | 
				
			||||||
		if ok {
 | 
							if ok {
 | 
				
			||||||
@@ -81,10 +81,12 @@ func (cc *clusterClientCache) syncService(key, clusterName string, clusterCache
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			glog.Infof("Found tombstone for %v", key)
 | 
								glog.Infof("Found tombstone for %v", key)
 | 
				
			||||||
			needUpdate = cc.processServiceDeletion(cachedService, clusterName)
 | 
								needUpdate = cc.processServiceDeletion(cachedService, clusterName)
 | 
				
			||||||
 | 
								isDeletion = true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		glog.Infof("Can not get service %v for cluster %s from serviceStore", key, clusterName)
 | 
							glog.Infof("Can not get service %v for cluster %s from serviceStore", key, clusterName)
 | 
				
			||||||
		needUpdate = cc.processServiceDeletion(cachedService, clusterName)
 | 
							needUpdate = cc.processServiceDeletion(cachedService, clusterName)
 | 
				
			||||||
 | 
							isDeletion = true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if needUpdate {
 | 
						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
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user