From 923e615602c0554cab364370fb38851003f1120e Mon Sep 17 00:00:00 2001 From: "igor.grzankowski" <@splunk.com> Date: Tue, 15 Jul 2025 15:09:56 +0200 Subject: [PATCH 1/5] Remove in progress phase --- api/v4/common_types.go | 6 ----- pkg/splunk/enterprise/afwscheduler.go | 30 ---------------------- pkg/splunk/enterprise/util.go | 8 ------ pkg/splunk/enterprise/util_test.go | 37 +++------------------------ 4 files changed, 3 insertions(+), 78 deletions(-) diff --git a/api/v4/common_types.go b/api/v4/common_types.go index 5bba9c0cd..dcf94f1c2 100644 --- a/api/v4/common_types.go +++ b/api/v4/common_types.go @@ -572,8 +572,6 @@ type PhaseInfo struct { const ( // AppPkgDownloadPending indicates pending AppPkgDownloadPending AppPhaseStatusType = 101 - // AppPkgDownloadInProgress indicates in progress - AppPkgDownloadInProgress = 102 // AppPkgDownloadComplete indicates complete AppPkgDownloadComplete = 103 // AppPkgDownloadError indicates error after retries @@ -583,8 +581,6 @@ const ( const ( // AppPkgPodCopyPending indicates pending AppPkgPodCopyPending AppPhaseStatusType = 201 - // AppPkgPodCopyInProgress indicates in progress - AppPkgPodCopyInProgress = 202 // AppPkgPodCopyComplete indicates complete AppPkgPodCopyComplete = 203 // AppPkgMissingFromOperator indicates the downloaded app package is missing @@ -596,8 +592,6 @@ const ( const ( // AppPkgInstallPending indicates pending AppPkgInstallPending AppPhaseStatusType = 301 - // AppPkgInstallInProgress indicates in progress - AppPkgInstallInProgress = 302 // AppPkgInstallComplete indicates complete AppPkgInstallComplete = 303 // AppPkgMissingOnPodError indicates app pkg is not available on Pod for install diff --git a/pkg/splunk/enterprise/afwscheduler.go b/pkg/splunk/enterprise/afwscheduler.go index cc99eca0d..99bf8ed68 100644 --- a/pkg/splunk/enterprise/afwscheduler.go +++ b/pkg/splunk/enterprise/afwscheduler.go @@ -37,11 +37,9 @@ import ( var appPhaseInfoStatuses = map[enterpriseApi.AppPhaseStatusType]bool{ enterpriseApi.AppPkgDownloadPending: true, - enterpriseApi.AppPkgDownloadInProgress: true, enterpriseApi.AppPkgDownloadComplete: true, enterpriseApi.AppPkgDownloadError: true, enterpriseApi.AppPkgPodCopyPending: true, - enterpriseApi.AppPkgPodCopyInProgress: true, enterpriseApi.AppPkgPodCopyComplete: true, enterpriseApi.AppPkgMissingFromOperator: true, enterpriseApi.AppPkgPodCopyError: true, @@ -557,34 +555,6 @@ downloadWork: continue } - // update the download state of app to be DownloadInProgress - updatePplnWorkerPhaseInfo(ctx, downloadWorker.appDeployInfo, downloadWorker.appDeployInfo.PhaseInfo.FailCount, enterpriseApi.AppPkgDownloadInProgress) - - appDeployInfo := downloadWorker.appDeployInfo - - // create the sub-directories on the volume for downloading scoped apps - localPath, err := downloadWorker.createDownloadDirOnOperator(ctx) - if err != nil { - scopedLog.Error(err, "unable to create download directory on operator", "appSrcName", downloadWorker.appSrcName, "appName", appDeployInfo.AppName) - - // increment the retry count and mark this app as download pending - updatePplnWorkerPhaseInfo(ctx, appDeployInfo, appDeployInfo.PhaseInfo.FailCount+1, enterpriseApi.AppPkgDownloadPending) - - <-downloadWorkersRunPool - continue - } - - // get the remoteDataClientMgr instance - remoteDataClientMgr, err := getRemoteDataClientMgr(ctx, downloadWorker.client, downloadWorker.cr, downloadWorker.afwConfig, downloadWorker.appSrcName) - if err != nil { - scopedLog.Error(err, "unable to get remote data client manager") - // increment the retry count and mark this app as download error - updatePplnWorkerPhaseInfo(ctx, appDeployInfo, appDeployInfo.PhaseInfo.FailCount+1, enterpriseApi.AppPkgDownloadError) - - <-downloadWorkersRunPool - continue - } - // increment the count in worker waitgroup downloadWorker.waiter.Add(1) diff --git a/pkg/splunk/enterprise/util.go b/pkg/splunk/enterprise/util.go index be352eb94..a6ee3e0ad 100644 --- a/pkg/splunk/enterprise/util.go +++ b/pkg/splunk/enterprise/util.go @@ -426,24 +426,18 @@ func appPhaseStatusAsStr(status enterpriseApi.AppPhaseStatusType) string { switch status { case enterpriseApi.AppPkgDownloadPending: return "Download Pending" - case enterpriseApi.AppPkgDownloadInProgress: - return "Download In Progress" case enterpriseApi.AppPkgDownloadComplete: return "Download Complete" case enterpriseApi.AppPkgDownloadError: return "Download Error" case enterpriseApi.AppPkgPodCopyPending: return "Pod Copy Pending" - case enterpriseApi.AppPkgPodCopyInProgress: - return "Pod Copy In Progress" case enterpriseApi.AppPkgPodCopyComplete: return "Pod Copy Complete" case enterpriseApi.AppPkgPodCopyError: return "Pod Copy Error" case enterpriseApi.AppPkgInstallPending: return "Install Pending" - case enterpriseApi.AppPkgInstallInProgress: - return "Install In Progress" case enterpriseApi.AppPkgInstallComplete: return "Install Complete" case enterpriseApi.AppPkgInstallError: @@ -458,8 +452,6 @@ func bundlePushStateAsStr(ctx context.Context, state enterpriseApi.BundlePushSta switch state { case enterpriseApi.BundlePushPending: return "Bundle Push Pending" - case enterpriseApi.BundlePushInProgress: - return "Bundle Push In Progress" case enterpriseApi.BundlePushComplete: return "Bundle Push Complete" default: diff --git a/pkg/splunk/enterprise/util_test.go b/pkg/splunk/enterprise/util_test.go index 5e69bfdb7..eed45f4dc 100644 --- a/pkg/splunk/enterprise/util_test.go +++ b/pkg/splunk/enterprise/util_test.go @@ -1098,11 +1098,6 @@ func TestAppPhaseStatusAsStr(t *testing.T) { t.Errorf("Got wrong status. Expected status=Download Pending, Got = %s", status) } - status = appPhaseStatusAsStr(enterpriseApi.AppPkgDownloadInProgress) - if status != "Download In Progress" { - t.Errorf("Got wrong status. Expected status=\"Download In Progress\", Got = %s", status) - } - status = appPhaseStatusAsStr(enterpriseApi.AppPkgDownloadComplete) if status != "Download Complete" { t.Errorf("Got wrong status. Expected status=\"Download Complete\", Got = %s", status) @@ -1113,36 +1108,11 @@ func TestAppPhaseStatusAsStr(t *testing.T) { t.Errorf("Got wrong status. Expected status=\"Download Error\", Got = %s", status) } - status = appPhaseStatusAsStr(enterpriseApi.AppPkgPodCopyPending) - if status != "Pod Copy Pending" { - t.Errorf("Got wrong status. Expected status=Pod Copy Pending, Got = %s", status) - } - - status = appPhaseStatusAsStr(enterpriseApi.AppPkgPodCopyInProgress) - if status != "Pod Copy In Progress" { - t.Errorf("Got wrong status. Expected status=\"Pod Copy In Progress\", Got = %s", status) - } - - status = appPhaseStatusAsStr(enterpriseApi.AppPkgPodCopyComplete) - if status != "Pod Copy Complete" { - t.Errorf("Got wrong status. Expected status=\"Pod Copy Complete\", Got = %s", status) - } - - status = appPhaseStatusAsStr(enterpriseApi.AppPkgPodCopyError) - if status != "Pod Copy Error" { - t.Errorf("Got wrong status. Expected status=\"Pod Copy Error\", Got = %s", status) - } - status = appPhaseStatusAsStr(enterpriseApi.AppPkgInstallPending) if status != "Install Pending" { t.Errorf("Got wrong status. Expected status=Install Pending, Got = %s", status) } - status = appPhaseStatusAsStr(enterpriseApi.AppPkgInstallInProgress) - if status != "Install In Progress" { - t.Errorf("Got wrong status. Expected status=\"Install In Progress\", Got = %s", status) - } - status = appPhaseStatusAsStr(enterpriseApi.AppPkgInstallComplete) if status != "Install Complete" { t.Errorf("Got wrong status. Expected status=\"Install Complete\", Got = %s", status) @@ -1161,10 +1131,9 @@ func TestAppPhaseStatusAsStr(t *testing.T) { func TestBundlePushStateAsStr(t *testing.T) { bpsMap := map[enterpriseApi.BundlePushStageType]string{ - enterpriseApi.BundlePushPending: "Bundle Push Pending", - enterpriseApi.BundlePushInProgress: "Bundle Push In Progress", - enterpriseApi.BundlePushComplete: "Bundle Push Complete", - 4: "Invalid bundle push state", + enterpriseApi.BundlePushPending: "Bundle Push Pending", + enterpriseApi.BundlePushComplete: "Bundle Push Complete", + 4: "Invalid bundle push state", } for k, v := range bpsMap { got := bundlePushStateAsStr(context.TODO(), k) From 8e5a1c8d66d6822d3f35bb4f6e8b1f284af33f84 Mon Sep 17 00:00:00 2001 From: "igor.grzankowski" <@splunk.com> Date: Tue, 15 Jul 2025 15:14:55 +0200 Subject: [PATCH 2/5] Bring back bundle push in progress --- pkg/splunk/enterprise/util.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/splunk/enterprise/util.go b/pkg/splunk/enterprise/util.go index a6ee3e0ad..2b4de465d 100644 --- a/pkg/splunk/enterprise/util.go +++ b/pkg/splunk/enterprise/util.go @@ -452,6 +452,8 @@ func bundlePushStateAsStr(ctx context.Context, state enterpriseApi.BundlePushSta switch state { case enterpriseApi.BundlePushPending: return "Bundle Push Pending" + case enterpriseApi.BundlePushInProgress: + return "Bundle Push In Progress" case enterpriseApi.BundlePushComplete: return "Bundle Push Complete" default: From 1283dae83a289734a475bc906a21836043612868 Mon Sep 17 00:00:00 2001 From: "igor.grzankowski" <@splunk.com> Date: Tue, 15 Jul 2025 16:09:35 +0200 Subject: [PATCH 3/5] fix --- pkg/splunk/enterprise/afwscheduler.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/splunk/enterprise/afwscheduler.go b/pkg/splunk/enterprise/afwscheduler.go index 99bf8ed68..b0f0a4cdc 100644 --- a/pkg/splunk/enterprise/afwscheduler.go +++ b/pkg/splunk/enterprise/afwscheduler.go @@ -44,7 +44,6 @@ var appPhaseInfoStatuses = map[enterpriseApi.AppPhaseStatusType]bool{ enterpriseApi.AppPkgMissingFromOperator: true, enterpriseApi.AppPkgPodCopyError: true, enterpriseApi.AppPkgInstallPending: true, - enterpriseApi.AppPkgInstallInProgress: true, enterpriseApi.AppPkgInstallComplete: true, enterpriseApi.AppPkgMissingOnPodError: true, enterpriseApi.AppPkgInstallError: true, @@ -558,6 +557,13 @@ downloadWork: // increment the count in worker waitgroup downloadWorker.waiter.Add(1) + appDeployInfo := downloadWorker.appDeployInfo + + remoteDataClientMgr, err := getRemoteDataClientMgr(ctx, downloadWorker.client, downloadWorker.cr, downloadWorker.afwConfig, downloadWorker.appSrcName) + localPath, err := downloadWorker.createDownloadDirOnOperator(ctx) + if err != nil { + scopedLog.Error(err, "unable to create download directory on operator", "appSrcName", downloadWorker.appSrcName, "appName", appDeployInfo.AppName) + } // start the actual download go downloadWorker.download(ctx, pplnPhase, *remoteDataClientMgr, localPath, downloadWorkersRunPool) From 12a4bba6966a6f26052b3804e1fc3dda3c7d4c13 Mon Sep 17 00:00:00 2001 From: "igor.grzankowski" <@splunk.com> Date: Tue, 15 Jul 2025 16:31:43 +0200 Subject: [PATCH 4/5] remove leftover status --- pkg/splunk/enterprise/afwscheduler_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/splunk/enterprise/afwscheduler_test.go b/pkg/splunk/enterprise/afwscheduler_test.go index 87c5f2ba8..28b71381f 100644 --- a/pkg/splunk/enterprise/afwscheduler_test.go +++ b/pkg/splunk/enterprise/afwscheduler_test.go @@ -3739,8 +3739,8 @@ func TestHandleAppPkgInstallComplete(t *testing.T) { // Standalone with only one replicas // Case-1: App pkg should not be deleted, when the installation is not complete on the Pod. worker.appDeployInfo.AuxPhaseInfo = append(worker.appDeployInfo.AuxPhaseInfo, enterpriseApi.PhaseInfo{ - Phase: enterpriseApi.PhaseInstall, - Status: enterpriseApi.AppPkgInstallInProgress}) + Phase: enterpriseApi.PhaseInstall, + }) _, err = os.Create(appPkgLocalPath) if err != nil { From a6f02a6cbcdea296718e21552ac0e1f3ca90698b Mon Sep 17 00:00:00 2001 From: "igor.grzankowski" <@splunk.com> Date: Tue, 15 Jul 2025 17:52:34 +0200 Subject: [PATCH 5/5] Add recover from panic. --- test/testenv/deployment.go | 5 +++++ test/testenv/testcaseenv.go | 5 +++++ test/testenv/testenv.go | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/test/testenv/deployment.go b/test/testenv/deployment.go index 85e753a84..262b2ff78 100644 --- a/test/testenv/deployment.go +++ b/test/testenv/deployment.go @@ -77,6 +77,11 @@ func (d *Deployment) popCleanupFunc() (cleanupFunc, error) { // Teardown teardowns the deployment resources func (d *Deployment) Teardown() error { + defer func() { + if r := recover(); r != nil { + d.testenv.Log.Error(fmt.Errorf("panic: %v", r), "Recovered from panic in Deployment.Teardown") + } + }() // Formatted string for pod logs podLogFile := "%s-%s.log" diff --git a/test/testenv/testcaseenv.go b/test/testenv/testcaseenv.go index a1081e0a0..a1a28642f 100644 --- a/test/testenv/testcaseenv.go +++ b/test/testenv/testcaseenv.go @@ -177,6 +177,11 @@ func (testenv *TestCaseEnv) setup() error { // Teardown cleanup the resources use in this testenv func (testenv *TestCaseEnv) Teardown() error { + defer func() { + if r := recover(); r != nil { + testenv.Log.Error(fmt.Errorf("panic: %v", r), "Recovered from panic in TestCaseEnv.Teardown") + } + }() if testenv.SkipTeardown && testenv.debug == "True" { testenv.Log.Info("testenv teardown is skipped!\n") diff --git a/test/testenv/testenv.go b/test/testenv/testenv.go index 7e4579ee2..5c97f7140 100644 --- a/test/testenv/testenv.go +++ b/test/testenv/testenv.go @@ -296,6 +296,11 @@ func (testenv *TestEnv) GetName() string { // Teardown cleanup the resources use in this testenv func (testenv *TestEnv) Teardown() error { + defer func() { + if r := recover(); r != nil { + testenv.Log.Error(fmt.Errorf("panic: %v", r), "Recovered from panic in TestEnv.Teardown") + } + }() if testenv.SkipTeardown && testenv.debug == "True" { testenv.Log.Info("testenv teardown is skipped!\n")