From 5227996e4a575000d6ae9d6e3c2b9e622b6c0e52 Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 31 Dec 2025 02:11:39 -0300 Subject: [PATCH 1/7] 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 b35ab2a34d9ef5d10c20606d3f94b06e8b8a25a8 Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 17 Dec 2025 23:53:14 -0300 Subject: [PATCH 2/7] 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 4fd89ba8b7775333675589d1d2043307528c62dd Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:37:56 -0300 Subject: [PATCH 3/7] 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 18cfd6af366bc775791d297e45553ebfd229e1e0 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:36:42 -0300 Subject: [PATCH 4/7] 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 595c4c3bbc071d97a153d246f1440af28cb525f0 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:35:55 -0300 Subject: [PATCH 5/7] Create `UpdateSecretWithTemplate` Signed-off-by: hamistao --- extensions/kubeapi/secrets/create.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/extensions/kubeapi/secrets/create.go b/extensions/kubeapi/secrets/create.go index 720e6ab2..39f89adf 100644 --- a/extensions/kubeapi/secrets/create.go +++ b/extensions/kubeapi/secrets/create.go @@ -33,3 +33,13 @@ func CreateSecretWithTemplate(client *rancher.Client, clusterID string, secretTe return createdSecret, nil } + +func UpdateSecretWithTemplate(client *rancher.Client, clusterID string, secretTemplate *corev1.Secret) error { + clusterContext, err := extclusterapi.GetClusterWranglerContext(client, clusterID) + if err != nil { + return fmt.Errorf("failed to get cluster context: %w", err) + } + + _, err = clusterContext.Core.Secret().Update(secretTemplate) + return err +} From 50e331b67f253bea87e6f198d5dfd337b402bd57 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:35:42 -0300 Subject: [PATCH 6/7] Remove redundant logic Signed-off-by: hamistao --- clients/rancher/v1/client.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/clients/rancher/v1/client.go b/clients/rancher/v1/client.go index 922f88d9..f2b7be49 100644 --- a/clients/rancher/v1/client.go +++ b/clients/rancher/v1/client.go @@ -138,10 +138,6 @@ func (c *Client) ProxyDownstream(clusterID string) (*Client, error) { updatedOpts.URL = proxyHost baseClient, err := clientbase.NewAPIClient(&updatedOpts) - if err != nil { - return nil, err - } - if err != nil { return nil, fmt.Errorf("failed creating Proxy Client. Backoff error: %v", err) } @@ -231,9 +227,7 @@ func (c *SteveClient) ListAll(params url.Values) (*SteveCollection, error) { resp = next resp.Data = data } - if err != nil { - return resp, err - } + return resp, err } @@ -387,9 +381,7 @@ func (c *NamespacedSteveClient) ListAll(params url.Values) (*SteveCollection, er resp = next resp.Data = data } - if err != nil { - return resp, err - } + return resp, err } From 893c6d922342ca8bdede4362239dedb5c2eb6f30 Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 15 Jul 2026 15:40:20 -0300 Subject: [PATCH 7/7] 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)