From 4b9f419572d32097f259efbb0ef48477758dfaf2 Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 31 Dec 2025 02:11:39 -0300 Subject: [PATCH 1/5] Add logging for missing cattle config Signed-off-by: hamistao --- pkg/config/config.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index c9758722..21b995a8 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -6,6 +6,7 @@ import ( "os" "github.com/creasty/defaults" + "github.com/sirupsen/logrus" "sigs.k8s.io/yaml" ) @@ -18,6 +19,7 @@ func LoadConfig(key string, config interface{}) { configPath := os.Getenv(ConfigEnvironmentKey) if configPath == "" { + logrus.Infof("No config file path provided via %s env var", ConfigEnvironmentKey) yaml.Unmarshal([]byte("{}"), config) return } From c4a0ba50a88ec4cea639cd58ccea3d39ceaa8ed7 Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 17 Dec 2025 23:53:14 -0300 Subject: [PATCH 2/5] Use Orphan Deletion Propagation Policy on cleanup This avoids a flood of useless messages on our tests such as: I1217 13:52:49.485450 12406 warnings.go:110] "Warning: child pods are preserved by default when jobs are deleted; set propagationPolicy=Background to remove them or set propagationPolicy=Orphan to suppress this warning" Signed-off-by: hamistao --- clients/dynamic/dynamic.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clients/dynamic/dynamic.go b/clients/dynamic/dynamic.go index b46ec3ec..a15168af 100644 --- a/clients/dynamic/dynamic.go +++ b/clients/dynamic/dynamic.go @@ -104,7 +104,9 @@ func (c *ResourceClient) Create(ctx context.Context, obj *unstructured.Unstructu if needsCleanup(obj) { c.ts.RegisterCleanupFunc(func() error { - err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{}, subresources...) + // Using this policy avoids a flood of useless warnings on test logs. + orphanPolicy := metav1.DeletePropagationOrphan + err := c.Delete(context.TODO(), unstructuredObj.GetName(), metav1.DeleteOptions{PropagationPolicy: &orphanPolicy}, subresources...) if errors.IsNotFound(err) { return nil } From e68959d1fc89628f270169d7e14581bf25ec49e7 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:37:56 -0300 Subject: [PATCH 3/5] Simplify error creation Signed-off-by: hamistao --- pkg/config/operations/operations.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkg/config/operations/operations.go b/pkg/config/operations/operations.go index 21b48e8e..7f67bed3 100644 --- a/pkg/config/operations/operations.go +++ b/pkg/config/operations/operations.go @@ -2,7 +2,6 @@ package operations import ( "encoding/json" - "errors" "fmt" "sigs.k8s.io/yaml" @@ -42,7 +41,7 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) { if len(keyPath) == 1 { keypathvalues, ok := searchMap[keyPath[0]] if !ok { - err = errors.New(fmt.Sprintf("expected key does not exist: %s", keyPath[0])) + err = fmt.Errorf("expected key does not exist: %s", keyPath[0]) } return keypathvalues, err } else { From b28aa63b2f23f9dbf180b39f7d3a3f339e4da101 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:36:42 -0300 Subject: [PATCH 4/5] Improve error on missing config key Signed-off-by: hamistao --- pkg/config/config.go | 5 ++++- pkg/config/operations/operations.go | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 21b995a8..eaa5af73 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -35,7 +35,10 @@ func LoadConfig(key string, config interface{}) { panic(err) } - scoped := all[key] + scoped, ok := all[key] + if !ok { + panic(fmt.Errorf("Key %s not present in provided config", key)) + } scopedString, err := yaml.Marshal(scoped) if err != nil { panic(err) diff --git a/pkg/config/operations/operations.go b/pkg/config/operations/operations.go index 7f67bed3..eee29b8b 100644 --- a/pkg/config/operations/operations.go +++ b/pkg/config/operations/operations.go @@ -65,7 +65,11 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) { // LoadObjectFromMap unmarshals a specific key's value into an object func LoadObjectFromMap(key string, config map[string]any, object any) { - keyConfig := config[key] + keyConfig, ok := config[key] + if !ok { + panic(fmt.Errorf("Key %s not present in provided config", key)) + } + scopedString, err := yaml.Marshal(keyConfig) if err != nil { panic(err) From 63e620bd09da4a20a29e2754e4e0c7aa66b57c46 Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 15 Jul 2026 15:40:42 -0300 Subject: [PATCH 5/5] log instead of panic --- pkg/config/config.go | 2 +- pkg/config/operations/operations.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index eaa5af73..9d21cf53 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -37,7 +37,7 @@ func LoadConfig(key string, config interface{}) { scoped, ok := all[key] if !ok { - panic(fmt.Errorf("Key %s not present in provided config", key)) + logrus.Infof("Key %s not present in provided config", key) } scopedString, err := yaml.Marshal(scoped) if err != nil { diff --git a/pkg/config/operations/operations.go b/pkg/config/operations/operations.go index eee29b8b..68f7feff 100644 --- a/pkg/config/operations/operations.go +++ b/pkg/config/operations/operations.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" + "github.com/sirupsen/logrus" "sigs.k8s.io/yaml" ) @@ -67,7 +68,7 @@ func GetValue(keyPath []string, searchMap map[string]any) (any, error) { func LoadObjectFromMap(key string, config map[string]any, object any) { keyConfig, ok := config[key] if !ok { - panic(fmt.Errorf("Key %s not present in provided config", key)) + logrus.Infof("Key %s not present in provided config", key) } scopedString, err := yaml.Marshal(keyConfig)