Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
fix: Workflow status now ignores unqueryable stacks (#138)
Browse files Browse the repository at this point in the history
fix: Workflow status now ignores unqueryable stacks
  • Loading branch information
elliot-smith authored Nov 9, 2021
1 parent 707c56e commit cf817a8
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 237 deletions.
59 changes: 38 additions & 21 deletions packages/cli/internal/pkg/aws/cfn/stack_filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,42 @@ package cfn

import "github.com/aws/aws-sdk-go-v2/service/cloudformation/types"

var ActiveStacksFilter = []types.StackStatus{
types.StackStatusCreateInProgress,
types.StackStatusCreateComplete,
types.StackStatusRollbackInProgress,
types.StackStatusRollbackFailed,
types.StackStatusRollbackComplete,
types.StackStatusDeleteInProgress,
types.StackStatusDeleteFailed,
types.StackStatusUpdateInProgress,
types.StackStatusUpdateCompleteCleanupInProgress,
types.StackStatusUpdateComplete,
types.StackStatusUpdateRollbackInProgress,
types.StackStatusUpdateRollbackFailed,
types.StackStatusUpdateRollbackCompleteCleanupInProgress,
types.StackStatusUpdateRollbackComplete,
types.StackStatusReviewInProgress,
types.StackStatusImportInProgress,
types.StackStatusImportComplete,
types.StackStatusImportRollbackInProgress,
types.StackStatusImportRollbackFailed,
types.StackStatusImportRollbackComplete,
type StackOptions struct {
activeStack bool
queryableStack bool
}

var stackDefinitions = map[types.StackStatus]StackOptions{
types.StackStatusCreateInProgress: {activeStack: true, queryableStack: false},
types.StackStatusCreateComplete: {activeStack: true, queryableStack: true},
types.StackStatusRollbackInProgress: {activeStack: true, queryableStack: false},
types.StackStatusRollbackFailed: {activeStack: true, queryableStack: false},
types.StackStatusRollbackComplete: {activeStack: true, queryableStack: false},
types.StackStatusDeleteInProgress: {activeStack: true, queryableStack: false},
types.StackStatusDeleteFailed: {activeStack: true, queryableStack: false},
types.StackStatusUpdateInProgress: {activeStack: true, queryableStack: true},
types.StackStatusUpdateCompleteCleanupInProgress: {activeStack: true, queryableStack: true},
types.StackStatusUpdateComplete: {activeStack: true, queryableStack: true},
types.StackStatusUpdateRollbackInProgress: {activeStack: true, queryableStack: true},
types.StackStatusUpdateRollbackFailed: {activeStack: true, queryableStack: true},
types.StackStatusUpdateRollbackCompleteCleanupInProgress: {activeStack: true, queryableStack: true},
types.StackStatusUpdateRollbackComplete: {activeStack: true, queryableStack: false},
types.StackStatusReviewInProgress: {activeStack: true, queryableStack: true},
types.StackStatusImportInProgress: {activeStack: true, queryableStack: true},
types.StackStatusImportComplete: {activeStack: true, queryableStack: true},
types.StackStatusImportRollbackInProgress: {activeStack: true, queryableStack: true},
types.StackStatusImportRollbackFailed: {activeStack: true, queryableStack: true},
types.StackStatusImportRollbackComplete: {activeStack: true, queryableStack: true},
}
var ActiveStacksFilter []types.StackStatus
var QueryableStacksMap map[types.StackStatus]bool

func init() {
QueryableStacksMap = make(map[types.StackStatus]bool)
for stackStatus, stackOptions := range stackDefinitions {
QueryableStacksMap[stackStatus] = stackOptions.queryableStack
if stackOptions.activeStack {
ActiveStacksFilter = append(ActiveStacksFilter, stackStatus)
}
}
}
6 changes: 4 additions & 2 deletions packages/cli/internal/pkg/cli/workflow/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,15 +331,17 @@ func (m *Manager) isContextDeployed(contextName string) bool {
return false
}
engineStackName := awsresources.RenderContextStackName(m.projectSpec.Name, contextName, m.userId)
_, err := m.Cfn.GetStackStatus(engineStackName)
status, err := m.Cfn.GetStackStatus(engineStackName)
if err != nil {
if errors.Is(err, cfn.StackDoesNotExistError) {
return false
}
m.err = err
return false
}
return true

ok, activeStatusFlag := cfn.QueryableStacksMap[status]
return ok && activeStatusFlag
}

func (m *Manager) setContext(contextName string) {
Expand Down
Loading

0 comments on commit cf817a8

Please sign in to comment.