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() }