From f3fb07de99d42d987f2a206b7a735f09afbff770 Mon Sep 17 00:00:00 2001 From: Arjun Kondur Date: Tue, 1 Oct 2024 20:19:18 -0500 Subject: [PATCH 1/3] Addresses PR#1372 --- pkg/splunk/enterprise/searchheadcluster.go | 4 ++-- pkg/splunk/enterprise/searchheadcluster_test.go | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/splunk/enterprise/searchheadcluster.go b/pkg/splunk/enterprise/searchheadcluster.go index fcaabe6cc..6cbef29f3 100644 --- a/pkg/splunk/enterprise/searchheadcluster.go +++ b/pkg/splunk/enterprise/searchheadcluster.go @@ -309,7 +309,7 @@ func ApplyShcSecret(ctx context.Context, mgr *searchHeadClusterPodManager, repli // Retrieve shc_secret password from Pod shcSecret, err := splutil.GetSpecificSecretTokenFromPod(ctx, mgr.c, shPodName, mgr.cr.GetNamespace(), "shc_secret") if err != nil { - return fmt.Errorf("couldn't retrieve shc_secret from secret data") + return fmt.Errorf("couldn't retrieve shc_secret from secret data, error: %s", err.Error()) } // set the targetPodName here @@ -320,7 +320,7 @@ func ApplyShcSecret(ctx context.Context, mgr *searchHeadClusterPodManager, repli // Retrieve admin password from Pod adminPwd, err := splutil.GetSpecificSecretTokenFromPod(ctx, mgr.c, shPodName, mgr.cr.GetNamespace(), "password") if err != nil { - return fmt.Errorf("couldn't retrieve admin password from secret data") + return fmt.Errorf("couldn't retrieve admin password from secret data, error: %s", err.Error()) } // If shc secret is different from namespace scoped secret change it diff --git a/pkg/splunk/enterprise/searchheadcluster_test.go b/pkg/splunk/enterprise/searchheadcluster_test.go index 8bc795308..6bc37c2c8 100644 --- a/pkg/splunk/enterprise/searchheadcluster_test.go +++ b/pkg/splunk/enterprise/searchheadcluster_test.go @@ -600,8 +600,10 @@ func TestApplyShcSecret(t *testing.T) { t.Errorf("Couldn't update resource") } + errMsg := fmt.Sprintf(splcommon.SecretTokenNotRetrievable, "shc_secret") + ", error: invalid secret data" + err = ApplyShcSecret(ctx, mgr, 1, mockPodExecClient) - if err.Error() != fmt.Sprintf(splcommon.SecretTokenNotRetrievable, "shc_secret") { + if err.Error() != errMsg { t.Errorf("Couldn't recognize missing shc_secret %s", err.Error()) } @@ -621,8 +623,9 @@ func TestApplyShcSecret(t *testing.T) { t.Errorf("Couldn't update resource") } + errMsg = fmt.Sprintf(splcommon.SecretTokenNotRetrievable, "admin password") + ", error: invalid secret data" err = ApplyShcSecret(ctx, mgr, 1, mockPodExecClient) - if err.Error() != fmt.Sprintf(splcommon.SecretTokenNotRetrievable, "admin password") { + if err.Error() != errMsg { t.Errorf("Couldn't recognize missing admin password %s", err.Error()) } From cc4fa4cd20bfbf91b4a0da4b7c456a8d7ee2539b Mon Sep 17 00:00:00 2001 From: Arjun Kondur Date: Wed, 9 Oct 2024 09:43:38 -0500 Subject: [PATCH 2/3] Change log --- pkg/splunk/enterprise/searchheadcluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/splunk/enterprise/searchheadcluster.go b/pkg/splunk/enterprise/searchheadcluster.go index 6cbef29f3..70d0d2e50 100644 --- a/pkg/splunk/enterprise/searchheadcluster.go +++ b/pkg/splunk/enterprise/searchheadcluster.go @@ -309,7 +309,7 @@ func ApplyShcSecret(ctx context.Context, mgr *searchHeadClusterPodManager, repli // Retrieve shc_secret password from Pod shcSecret, err := splutil.GetSpecificSecretTokenFromPod(ctx, mgr.c, shPodName, mgr.cr.GetNamespace(), "shc_secret") if err != nil { - return fmt.Errorf("couldn't retrieve shc_secret from secret data, error: %s", err.Error()) + return fmt.Errorf("couldn't retrieve shc secret from secret data, error: %s", err.Error()) } // set the targetPodName here From e1718cde0d3cae0a58b80066987055a63f58c2c6 Mon Sep 17 00:00:00 2001 From: Arjun Kondur Date: Wed, 9 Oct 2024 09:52:41 -0500 Subject: [PATCH 3/3] Change log --- pkg/splunk/enterprise/searchheadcluster.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/splunk/enterprise/searchheadcluster.go b/pkg/splunk/enterprise/searchheadcluster.go index 70d0d2e50..6cbef29f3 100644 --- a/pkg/splunk/enterprise/searchheadcluster.go +++ b/pkg/splunk/enterprise/searchheadcluster.go @@ -309,7 +309,7 @@ func ApplyShcSecret(ctx context.Context, mgr *searchHeadClusterPodManager, repli // Retrieve shc_secret password from Pod shcSecret, err := splutil.GetSpecificSecretTokenFromPod(ctx, mgr.c, shPodName, mgr.cr.GetNamespace(), "shc_secret") if err != nil { - return fmt.Errorf("couldn't retrieve shc secret from secret data, error: %s", err.Error()) + return fmt.Errorf("couldn't retrieve shc_secret from secret data, error: %s", err.Error()) } // set the targetPodName here