From 9b9cb81199763c9b239fdc8bfcf81e0b9c935f01 Mon Sep 17 00:00:00 2001 From: owensmallwood Date: Thu, 5 Dec 2024 13:14:04 -0600 Subject: [PATCH] Unified Storage Search: Check error first after building index (#97504) check error first after building index --- pkg/storage/unified/resource/search.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/storage/unified/resource/search.go b/pkg/storage/unified/resource/search.go index 63c2cf24507..9ea3a321a36 100644 --- a/pkg/storage/unified/resource/search.go +++ b/pkg/storage/unified/resource/search.go @@ -355,6 +355,10 @@ func (s *searchSupport) build(ctx context.Context, nsr NamespacedResource, size return rv, err }) + if err != nil { + return nil, 0, err + } + // Record the number of objects indexed for the kind/resource docCount, err := index.DocCount() if err != nil { @@ -364,10 +368,6 @@ func (s *searchSupport) build(ctx context.Context, nsr NamespacedResource, size IndexMetrics.IndexedKinds.WithLabelValues(key.Resource).Add(float64(docCount)) } - if err != nil { - return nil, 0, err - } - if err == nil { err = index.Flush() }