From 1794fa5aeda79a19d0390ed53746178cf9b57049 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Sat, 22 Jun 2024 14:37:02 +0530 Subject: [PATCH 1/2] chore: (k8s) return explicit error in case of insufficient access --- scrapers/kubernetes/kubernetes.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scrapers/kubernetes/kubernetes.go b/scrapers/kubernetes/kubernetes.go index 1c67ed03..1a928423 100644 --- a/scrapers/kubernetes/kubernetes.go +++ b/scrapers/kubernetes/kubernetes.go @@ -2,6 +2,7 @@ package kubernetes import ( "encoding/json" + "errors" "fmt" "regexp" "strconv" @@ -25,6 +26,7 @@ import ( "github.com/flanksource/is-healthy/pkg/health" "github.com/flanksource/is-healthy/pkg/lua" "github.com/flanksource/ketall" + ketallClient "github.com/flanksource/ketall/client" "github.com/flanksource/ketall/options" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) @@ -156,6 +158,9 @@ func (kubernetes KubernetesScraper) Scrape(ctx api.ScrapeContext) v1.ScrapeResul objs, err := ketall.KetAll(ctx, opts) if err != nil { + if errors.Is(err, ketallClient.ErrEmpty) { + return results.Errorf(fmt.Errorf("no resources returned due to insufficient access"), "failed to fetch resources") + } return results.Errorf(err, "failed to fetch resources") } From 5ef24a73105e4993272fd690a48f89ed28f43979 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Mon, 24 Jun 2024 11:56:28 +0530 Subject: [PATCH 2/2] chore: bump ketall --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8e01a728..36fe71c0 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( github.com/flanksource/commons v1.22.1 github.com/flanksource/duty v1.0.500 github.com/flanksource/is-healthy v1.0.10 - github.com/flanksource/ketall v1.1.6 + github.com/flanksource/ketall v1.1.7 github.com/flanksource/mapstructure v1.6.0 github.com/go-logr/zapr v1.2.4 github.com/gobwas/glob v0.2.3 diff --git a/go.sum b/go.sum index eff47464..dfacfb0a 100644 --- a/go.sum +++ b/go.sum @@ -862,8 +862,8 @@ github.com/flanksource/gomplate/v3 v3.24.2/go.mod h1:94BxYobZqouGdVezuz6LNto5C+y github.com/flanksource/is-healthy v0.0.0-20230705092916-3b4cf510c5fc/go.mod h1:4pQhmF+TnVqJroQKY8wSnSp+T18oLson6YQ2M0qPHfQ= github.com/flanksource/is-healthy v1.0.10 h1:g7cyLTK/a5PqTJmRG35+4l7I6vzQqGAQAxpwrw0efkE= github.com/flanksource/is-healthy v1.0.10/go.mod h1:ijdyDDpdRzDtIt1UVZv5WNpAnb8V4hGUz75rnr3Ubhk= -github.com/flanksource/ketall v1.1.6 h1:gGZsbDUf4ULznNMEC076cyrhGAZbaRnZXuhZ42PTyaE= -github.com/flanksource/ketall v1.1.6/go.mod h1:s76Y3Anqptx5CdP4Jtav3LWjAu297ME8YXEsAiw/NcE= +github.com/flanksource/ketall v1.1.7 h1:PrbcZ3mZepu5Tit2PI0EfxYtTw5sHn9X4kE3JZjvwto= +github.com/flanksource/ketall v1.1.7/go.mod h1:s76Y3Anqptx5CdP4Jtav3LWjAu297ME8YXEsAiw/NcE= github.com/flanksource/kommons v0.31.4 h1:zksAgYjZuwPgS8XTejDIWEYB0nPSU1i3Jxcavm/vovI= github.com/flanksource/kommons v0.31.4/go.mod h1:70BPMzjTvejsqRyVyAm/ZCeZ176toCvauaZjU03svnE= github.com/flanksource/kubectl-neat v1.0.4 h1:t5/9CqgE84oEtB0KitgJ2+WIeLfD+RhXSxYrqb4X8yI=