Skip to content

Commit f21f1b7

Browse files
authored
Merge pull request #788 from Iceber/handle_orphan_event
EventsSynchro: handle orphan events
2 parents c347d5a + c890efb commit f21f1b7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/synchromanager/clustersynchro/default_resource_synchro.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,11 +693,27 @@ func (synchro *eventSynchro) Start(stop <-chan struct{}) {
693693
informer.NewResourceVersionInformer(synchro.cluster, config).Run(stop)
694694
}
695695

696+
func (synchro *eventSynchro) isOrphanEvent(event *corev1.Event) bool {
697+
key := cache.NewObjectName(event.InvolvedObject.Namespace, event.InvolvedObject.Name).String()
698+
synchro.synchro.rvsLock.Lock()
699+
_, ok := synchro.synchro.rvs[key]
700+
synchro.synchro.rvsLock.Unlock()
701+
return !ok
702+
}
703+
696704
func (synchro *eventSynchro) OnAdd(obj interface{}, _ bool) {
705+
if synchro.isOrphanEvent(obj.(*corev1.Event)) {
706+
// TODO(Iceber): cache orphan events
707+
return
708+
}
697709
_ = synchro.queue.Add(obj, false)
698710
}
699711

700712
func (synchro *eventSynchro) OnUpdate(_, obj interface{}, _ bool) {
713+
if synchro.isOrphanEvent(obj.(*corev1.Event)) {
714+
// TODO(Iceber): cache orphan events
715+
return
716+
}
701717
_ = synchro.queue.Update(obj, false)
702718
}
703719

0 commit comments

Comments
 (0)