From 6d6af6597bfb36b684e7553d66ac4adb00972b8c Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Fri, 8 Jul 2022 08:13:41 +0200 Subject: [PATCH] Return empty result for no stats Signed-off-by: Filip Petkovski --- pkg/api/status/v1.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/api/status/v1.go b/pkg/api/status/v1.go index 0f10a5b5b8..b0681c86d0 100644 --- a/pkg/api/status/v1.go +++ b/pkg/api/status/v1.go @@ -17,7 +17,6 @@ package status import ( - "fmt" "net/http" "github.com/prometheus/client_golang/prometheus" @@ -95,8 +94,9 @@ func (sapi *StatusAPI) httpServeStats(r *http.Request) (interface{}, []error, *a return nil, nil, sterr } - if stats == nil { - return nil, nil, &api.ApiError{Typ: api.ErrorBadData, Err: fmt.Errorf("unknown tenant")} + result := make([]TSDBStatus, 0, len(stats)) + if len(stats) == 0 { + return result, nil, nil } metrics, err := sapi.registry.Gather() @@ -119,7 +119,6 @@ func (sapi *StatusAPI) httpServeStats(r *http.Request) (interface{}, []error, *a } } - result := make([]TSDBStatus, 0, len(stats)) for _, s := range stats { var chunkCount int64 if c, ok := tenantChunks[s.Tenant]; ok {