Skip to content

Commit d9c043a

Browse files
committed
skip cache add for DeletedFinaleStateUnknown
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com> del unused ok Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
1 parent cd14304 commit d9c043a

File tree

1 file changed

+20
-0
lines changed
  • images/virtualization-artifact/pkg/audit/informer

1 file changed

+20
-0
lines changed

images/virtualization-artifact/pkg/audit/informer/informer.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ func NewInformerList(ctx context.Context, kubeCfg *rest.Config, ttlCache cache)
6868
vmInformer := virtSharedInformerFactory.Virtualization().V1alpha2().VirtualMachines().Informer()
6969
_, err = vmInformer.AddEventHandler(kubecache.ResourceEventHandlerFuncs{
7070
DeleteFunc: func(obj any) {
71+
_, ok := obj.(kubecache.DeletedFinalStateUnknown)
72+
if ok {
73+
return
74+
}
75+
7176
vm := obj.(*v1alpha2.VirtualMachine)
7277
key := fmt.Sprintf("virtualmachines/%s/%s", vm.Namespace, vm.Name)
7378
ttlCache.Add(key, vm)
@@ -82,6 +87,11 @@ func NewInformerList(ctx context.Context, kubeCfg *rest.Config, ttlCache cache)
8287
vdInformer := virtSharedInformerFactory.Virtualization().V1alpha2().VirtualDisks().Informer()
8388
_, err = vdInformer.AddEventHandler(kubecache.ResourceEventHandlerFuncs{
8489
DeleteFunc: func(obj any) {
90+
_, ok := obj.(kubecache.DeletedFinalStateUnknown)
91+
if ok {
92+
return
93+
}
94+
8595
vd := obj.(*v1alpha2.VirtualDisk)
8696
key := fmt.Sprintf("pods/%s/%s", vd.Namespace, vd.Name)
8797
ttlCache.Add(key, vd)
@@ -96,6 +106,11 @@ func NewInformerList(ctx context.Context, kubeCfg *rest.Config, ttlCache cache)
96106
podInformer := coreSharedInformerFactory.Core().V1().Pods().Informer()
97107
_, err = podInformer.AddEventHandler(kubecache.ResourceEventHandlerFuncs{
98108
DeleteFunc: func(obj any) {
109+
_, ok := obj.(kubecache.DeletedFinalStateUnknown)
110+
if ok {
111+
return
112+
}
113+
99114
pod := obj.(*corev1.Pod)
100115
key := fmt.Sprintf("pods/%s/%s", pod.Namespace, pod.Name)
101116
ttlCache.Add(key, pod)
@@ -110,6 +125,11 @@ func NewInformerList(ctx context.Context, kubeCfg *rest.Config, ttlCache cache)
110125
internalVMIInformer := GetInternalVMIInformer(dynamicInformerFactory).Informer()
111126
_, err = internalVMIInformer.AddEventHandler(kubecache.ResourceEventHandlerFuncs{
112127
DeleteFunc: func(obj any) {
128+
_, ok := obj.(kubecache.DeletedFinalStateUnknown)
129+
if ok {
130+
return
131+
}
132+
113133
unstructuredObj, ok := obj.(*unstructured.Unstructured)
114134
if !ok {
115135
return

0 commit comments

Comments
 (0)