From 0ed4a1885534af45cbddbf48bccce2260e45649f Mon Sep 17 00:00:00 2001 From: Ashish Tiwari Date: Fri, 1 Dec 2023 15:36:09 +0530 Subject: [PATCH] fix: fallback to create when resource isn't found while update (#24) --- pkg/adapter/etcd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/adapter/etcd.go b/pkg/adapter/etcd.go index 1488c08..06faee7 100644 --- a/pkg/adapter/etcd.go +++ b/pkg/adapter/etcd.go @@ -163,10 +163,13 @@ func (a *adapter) handleUpdateEvent(ctx context.Context, ev *Event) { return } if prevKV == nil { - log.Error("object not found (during update event), ignore it", + log.Info("object not found (during update event), ignore it", zap.Int64("revision", rev), zap.String("key", ev.Key), ) + // Fallback to add event when the resource isn't found + ev.Type = EventAdd + a.handleAddEvent(ctx, ev) return } rev, prev, ok, err := a.backend.Update(ctx, ev.Key, ev.Value, prevKV.ModRevision, 0)