From b21d3f9b82b8216c2599ef5d293bc4a8e7f103f7 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 23 Feb 2023 08:29:14 -0800 Subject: [PATCH] event target registration failures must be returned (#16700) --- internal/event/target/lazyinit.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/internal/event/target/lazyinit.go b/internal/event/target/lazyinit.go index 728005b68..695da1978 100644 --- a/internal/event/target/lazyinit.go +++ b/internal/event/target/lazyinit.go @@ -41,10 +41,11 @@ func (l *lazyInit) doSlow(f func() error) error { l.m.Lock() defer l.m.Unlock() if atomic.LoadUint32(&l.done) == 0 { - if f() == nil { - // Mark as done only when f() is successful - atomic.StoreUint32(&l.done, 1) + if err := f(); err != nil { + return err } + // Mark as done only when f() is successful + atomic.StoreUint32(&l.done, 1) } return nil }