Skip to content

Commit

Permalink
support configmap delete (#791)
Browse files Browse the repository at this point in the history
  • Loading branch information
huiwq1990 authored Apr 8, 2022
1 parent 8425f27 commit 3c0e94d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/yurthub/cachemanager/cache_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (cm *cacheManager) initCacheAgents() error {
configmapInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: cm.addConfigmap,
UpdateFunc: cm.updateConfigmap,
DeleteFunc: cm.deleteConfigmap,
})

klog.Infof("init cache agents to %v", cm.cacheAgents)
Expand Down Expand Up @@ -74,6 +75,16 @@ func (cm *cacheManager) updateConfigmap(oldObj, newObj interface{}) {
cm.deleteAgentCache(deletedAgents)
}

func (cm *cacheManager) deleteConfigmap(obj interface{}) {
_, ok := obj.(*corev1.ConfigMap)
if !ok {
return
}

deletedAgents := cm.updateCacheAgents("", "delete")
cm.deleteAgentCache(deletedAgents)
}

// updateCacheAgents update cache agents
func (cm *cacheManager) updateCacheAgents(cacheAgents, action string) sets.String {
newAgents := sets.NewString()
Expand Down

0 comments on commit 3c0e94d

Please sign in to comment.