Skip to content

Draft: Remove In progress phases from afw. #1538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions api/v4/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
30 changes: 3 additions & 27 deletions pkg/splunk/enterprise/afwscheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ 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,
enterpriseApi.AppPkgInstallPending: true,
enterpriseApi.AppPkgInstallInProgress: true,
enterpriseApi.AppPkgInstallComplete: true,
enterpriseApi.AppPkgMissingOnPodError: true,
enterpriseApi.AppPkgInstallError: true,
Expand Down Expand Up @@ -557,37 +554,16 @@ downloadWork:
continue
}

// update the download state of app to be DownloadInProgress
updatePplnWorkerPhaseInfo(ctx, downloadWorker.appDeployInfo, downloadWorker.appDeployInfo.PhaseInfo.FailCount, enterpriseApi.AppPkgDownloadInProgress)
// increment the count in worker waitgroup
downloadWorker.waiter.Add(1)

appDeployInfo := downloadWorker.appDeployInfo

// create the sub-directories on the volume for downloading scoped apps
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)

// 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)

// start the actual download
go downloadWorker.download(ctx, pplnPhase, *remoteDataClientMgr, localPath, downloadWorkersRunPool)

Expand Down
4 changes: 2 additions & 2 deletions pkg/splunk/enterprise/afwscheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 0 additions & 6 deletions pkg/splunk/enterprise/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
37 changes: 3 additions & 34 deletions pkg/splunk/enterprise/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions test/testenv/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 5 additions & 0 deletions test/testenv/testcaseenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions test/testenv/testenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading