From 7e4504dfd96aacf1a4064c1abe543ac24c43cb33 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:35:42 -0300 Subject: [PATCH 1/6] 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 738d6396..62f87150 100644 --- a/clients/rancher/v1/client.go +++ b/clients/rancher/v1/client.go @@ -143,10 +143,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) } @@ -236,9 +232,7 @@ func (c *SteveClient) ListAll(params url.Values) (*SteveCollection, error) { resp = next resp.Data = data } - if err != nil { - return resp, err - } + return resp, err } @@ -392,9 +386,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 3a8bc1ac54b063011a97ac94821c52ec7d4fa0b7 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:35:55 -0300 Subject: [PATCH 2/6] 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 f8fb07b5fbe6dcf9d79d176fd19043bceaed3964 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:36:42 -0300 Subject: [PATCH 3/6] Improve error on missing config key Signed-off-by: hamistao --- pkg/config/config.go | 6 +++++- pkg/config/operations/operations.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index c9758722..25961122 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" ) @@ -33,7 +34,10 @@ func LoadConfig(key string, config interface{}) { panic(err) } - scoped := all[key] + scoped, ok := all[key] + if !ok { + logrus.Infof("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 21b48e8e..1b4a9554 100644 --- a/pkg/config/operations/operations.go +++ b/pkg/config/operations/operations.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" + "github.com/sirupsen/logrus" "sigs.k8s.io/yaml" ) @@ -66,7 +67,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 { + logrus.Infof("Key %s not present in provided config", key) + } + scopedString, err := yaml.Marshal(keyConfig) if err != nil { panic(err) From 103cabbe32b6fdc372e2f5d0625bdc96629c8085 Mon Sep 17 00:00:00 2001 From: hamistao Date: Mon, 13 Jul 2026 10:37:56 -0300 Subject: [PATCH 4/6] 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 1b4a9554..68f7feff 100644 --- a/pkg/config/operations/operations.go +++ b/pkg/config/operations/operations.go @@ -2,7 +2,6 @@ package operations import ( "encoding/json" - "errors" "fmt" "github.com/sirupsen/logrus" @@ -43,7 +42,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 bdcd98e5df3534c9b0fecae967ab99c620be4615 Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 17 Dec 2025 23:53:14 -0300 Subject: [PATCH 5/6] 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 4dcaafb2c48f10e573deef05e6adb6e80d55f0ed Mon Sep 17 00:00:00 2001 From: hamistao Date: Wed, 31 Dec 2025 02:11:39 -0300 Subject: [PATCH 6/6] Add logging for missing cattle config Signed-off-by: hamistao --- pkg/config/config.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 25961122..9d21cf53 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -19,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 }