From 2ab24144d19aa94dfdd45ab30d2a3a9ebd36c656 Mon Sep 17 00:00:00 2001 From: derailed Date: Wed, 21 Feb 2024 10:56:08 -0700 Subject: [PATCH 1/2] [Bug] Fix #284 --- internal/db/db.go | 7 ++++--- internal/lint/cronjob.go | 2 +- internal/lint/gw.go | 9 ++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/db/db.go b/internal/db/db.go index 03bdef59..f71b5c1f 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -30,8 +30,9 @@ func NewDB(db *memdb.MemDB) *DB { func (db *DB) ITFor(gvr types.GVR) (*memdb.Txn, memdb.ResultIterator, error) { if gvr == types.BlankGVR { - panic(fmt.Errorf("invalid table")) + return nil, nil, fmt.Errorf("invalid table") } + txn := db.Txn(false) it, err := txn.Get(gvr.String(), "id") if err != nil { @@ -45,7 +46,7 @@ func (db *DB) MustITForNS(gvr types.GVR, ns string) (*memdb.Txn, memdb.ResultIte txn := db.Txn(false) it, err := txn.Get(gvr.String(), "ns", ns) if err != nil { - panic(fmt.Errorf("Db get failed for %q: %w", gvr, err)) + panic(fmt.Errorf("db ns iterator failed for %q: %w", gvr, err)) } return txn, it @@ -55,7 +56,7 @@ func (db *DB) MustITFor(gvr types.GVR) (*memdb.Txn, memdb.ResultIterator) { txn := db.Txn(false) it, err := txn.Get(gvr.String(), "id") if err != nil { - panic(fmt.Errorf("Db get failed for %q: %w", gvr, err)) + panic(fmt.Errorf("db iterator failed for %q: %w", gvr, err)) } return txn, it diff --git a/internal/lint/cronjob.go b/internal/lint/cronjob.go index c893407f..a0c102fc 100644 --- a/internal/lint/cronjob.go +++ b/internal/lint/cronjob.go @@ -125,7 +125,7 @@ func jobResourceUsage(ctx context.Context, dba *db.DB, c Collector, jobs []*batc mx.RequestMEM.Add(mem) pmx, err := dba.FindPMX(fqn) - if err != nil { + if err != nil || pmx == nil { continue } for _, cx := range pmx.Containers { diff --git a/internal/lint/gw.go b/internal/lint/gw.go index f5b37539..e4d1218b 100644 --- a/internal/lint/gw.go +++ b/internal/lint/gw.go @@ -11,6 +11,7 @@ import ( "github.com/derailed/popeye/internal/client" "github.com/derailed/popeye/internal/db" "github.com/derailed/popeye/internal/issues" + "github.com/rs/zerolog/log" gwv1 "sigs.k8s.io/gateway-api/apis/v1" ) @@ -47,9 +48,11 @@ func (s *Gateway) Lint(ctx context.Context) error { } func (s *Gateway) checkRefs(ctx context.Context, gw *gwv1.Gateway) { - txn := s.db.Txn(false) - defer txn.Abort() - txn, it := s.db.MustITFor(internal.Glossary[internal.GWC]) + txn, it, err := s.db.ITFor(internal.Glossary[internal.GWC]) + if err != nil { + log.Warn().Err(err).Msg("no gateway class located. Skipping gw ref check") + return + } defer txn.Abort() for o := it.Next(); o != nil; o = it.Next() { From f0630f7445051f1efea9e43e5a4387d8328d14af Mon Sep 17 00:00:00 2001 From: derailed Date: Wed, 21 Feb 2024 10:57:59 -0700 Subject: [PATCH 2/2] [Maint] Release notes --- Makefile | 2 +- README.md | 45 +++++++++++++++++++--------------- change_logs/release_v0.20.3.md | 25 +++++++++++++++++++ 3 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 change_logs/release_v0.20.3.md diff --git a/Makefile b/Makefile index 8b5a1a5c..456d0afa 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ NAME := popeye PACKAGE := github.com/derailed/$(NAME) -VERSION := v0.20.2 +VERSION := v0.20.3 GIT := $(shell git rev-parse --short HEAD) DATE := $(shell date +%FT%T%Z) IMG_NAME := derailed/popeye diff --git a/README.md b/README.md index 6bfa17de..65942eb9 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,31 @@ Popeye is available on Linux, OSX and Windows platforms. --- +## The Command Line + +You can use Popeye wide open or using a spinach yaml config to +tune your linters. Details about the Popeye configuration file are below. + +```shell +# Dump version info and logs location +popeye version +# Popeye a cluster using your current kubeconfig environment. +# NOTE! This will run Popeye in the context namespace if set or like kubectl will use the default namespace +popeye +# Run Popeye in the `fred` namespace +popeye -n fred +# Run Popeye in all namespaces +popeye -A +# Popeye uses a spinach config file of course! aka spinachyaml! +popeye -f spinach.yaml +# Popeye a cluster using a kubeconfig context. +popeye --context olive +# Stuck? +popeye help +``` + +--- + ## Linters Popeye scans your cluster for best practices and potential issues. @@ -274,26 +299,6 @@ cat /tmp/popeye/my_report.txt --- -## The Command Line - -You can use Popeye wide open or using a spinach yaml config to -tune your linters. Details about the Popeye configuration file are below. - -```shell -# Dump version info and logs location -popeye version -# Popeye a cluster using your current kubeconfig environment. -popeye -# Popeye uses a spinach config file of course! aka spinachyaml! -popeye -f spinach.yaml -# Popeye a cluster using a kubeconfig context. -popeye --context olive -# Stuck? -popeye help -``` - ---- - ## Output Formats Popeye can generate linter reports in a variety of formats. You can use the -o cli option and pick your poison from there. diff --git a/change_logs/release_v0.20.3.md b/change_logs/release_v0.20.3.md new file mode 100644 index 00000000..c4725707 --- /dev/null +++ b/change_logs/release_v0.20.3.md @@ -0,0 +1,25 @@ + + +# Release v0.20.3 + +## Notes + +Thank you to all that contributed with flushing out issues and enhancements for Popeye! I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev and see if we're happier with some of the fixes! If you've filed an issue please help me verify and close. Your support, kindness and awesome suggestions to make Popeye better is as ever very much noticed and appreciated! + +This project offers a GitHub Sponsor button (over here 👆). As you well know this is not pimped out by big corps with deep pockets. If you feel `Popeye` is saving you cycles diagnosing potential cluster issues please consider sponsoring this project!! It does go a long way in keeping our servers lights on and beers in our fridge. + +Also if you dig this tool, please make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer) + +--- + +## Maintenance Release + +--- + +## Resolved Issues + +. [#284](https://github.com/derailed/popeye/issues/284) Db get failed for "" + +--- + +  © 2024 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)