diff --git a/test/e2e/fixtures/when.go b/test/e2e/fixtures/when.go index 4fbff966cd58..586668ad606c 100644 --- a/test/e2e/fixtures/when.go +++ b/test/e2e/fixtures/when.go @@ -166,25 +166,16 @@ func (w *When) CreateCronWorkflow() *When { type Condition func(wf *wfv1.Workflow) (bool, string) var ( + ToBeRunning = ToHavePhase(wfv1.WorkflowRunning) + ToBeSucceeded = ToHavePhase(wfv1.WorkflowSucceeded) + ToBeErrored = ToHavePhase(wfv1.WorkflowError) + ToBeFailed = ToHavePhase(wfv1.WorkflowFailed) ToBeCompleted Condition = func(wf *wfv1.Workflow) (bool, string) { return wf.Labels[common.LabelKeyCompleted] == "true", "to be completed" } - ToStart Condition = func(wf *wfv1.Workflow) (bool, string) { return !wf.Status.StartedAt.IsZero(), "to start" } - ToBeRunning Condition = func(wf *wfv1.Workflow) (bool, string) { - return wf.Status.Nodes.Any(func(node wfv1.NodeStatus) bool { - return node.Phase == wfv1.NodeRunning - }), "to be running" - } + ToStart Condition = func(wf *wfv1.Workflow) (bool, string) { return !wf.Status.StartedAt.IsZero(), "to start" } ) -var ToBeSucceeded Condition = func(wf *wfv1.Workflow) (bool, string) { - return wf.Status.Phase == wfv1.WorkflowSucceeded, "to be succeeded" -} - -var ToBeFailed Condition = func(wf *wfv1.Workflow) (bool, string) { - return wf.Status.Phase == wfv1.WorkflowFailed, "to be failed" -} - // `ToBeDone` replaces `ToFinish` which also makes sure the workflow is both complete not pending archiving. // This additional check is not needed for most use case, however in `AfterTest` we delete the workflow and this // creates a lot of warning messages in the logs that are cause by misuse rather than actual problems. @@ -197,6 +188,12 @@ var ToBeArchived Condition = func(wf *wfv1.Workflow) (bool, string) { return wf.Labels[common.LabelKeyWorkflowArchivingStatus] == "Archived", "to be archived" } +var ToHavePhase = func(p wfv1.WorkflowPhase) Condition { + return func(wf *wfv1.Workflow) (bool, string) { + return wf.Status.Phase == p && wf.Labels[common.LabelKeyWorkflowArchivingStatus] != "Pending", fmt.Sprintf("to be %s", p) + } +} + var ToBeWaitingOnAMutex Condition = func(wf *wfv1.Workflow) (bool, string) { return wf.Status.Synchronization != nil && wf.Status.Synchronization.Mutex != nil, "to be waiting on a mutub" } diff --git a/workflow/controller/indexes/workflow_index.go b/workflow/controller/indexes/workflow_index.go index 9fb19df1e091..f92e83f8f952 100644 --- a/workflow/controller/indexes/workflow_index.go +++ b/workflow/controller/indexes/workflow_index.go @@ -12,9 +12,7 @@ import ( "github.com/argoproj/argo-workflows/v3/workflow/util" ) -var ( - indexWorkflowSemaphoreKeys = os.Getenv("INDEX_WORKFLOW_SEMAPHORE_KEYS") != "false" -) +var indexWorkflowSemaphoreKeys = os.Getenv("INDEX_WORKFLOW_SEMAPHORE_KEYS") != "false" func init() { log.WithField("indexWorkflowSemaphoreKeys", indexWorkflowSemaphoreKeys).Info("index config") diff --git a/workflow/cron/controller.go b/workflow/cron/controller.go index 5b8945ec1ada..46224dc1bf26 100644 --- a/workflow/cron/controller.go +++ b/workflow/cron/controller.go @@ -6,8 +6,6 @@ import ( "reflect" "time" - "github.com/argoproj/argo-workflows/v3/util/env" - "github.com/argoproj/pkg/sync" log "github.com/sirupsen/logrus" apiv1 "k8s.io/api/core/v1" @@ -28,6 +26,7 @@ import ( "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow" "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned" + "github.com/argoproj/argo-workflows/v3/util/env" "github.com/argoproj/argo-workflows/v3/workflow/events" "github.com/argoproj/argo-workflows/v3/workflow/metrics" "github.com/argoproj/argo-workflows/v3/workflow/util" @@ -56,9 +55,7 @@ const ( cronWorkflowWorkers = 8 ) -var ( - cronSyncPeriod = env.LookupEnvDurationOr("CRON_SYNC_PERIOD", 10*time.Second) -) +var cronSyncPeriod = env.LookupEnvDurationOr("CRON_SYNC_PERIOD", 10*time.Second) func init() { // this make sure we support timezones