Skip to content

Commit

Permalink
feat: SKIP_WORKFLOW_DURATION_ESTIMATION. Fixes #7271 (#13745)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gilgur <[email protected]>
Co-authored-by: Anton Gilgur <[email protected]>
Co-authored-by: Taleb Zeghmi <[email protected]>
  • Loading branch information
3 people authored Oct 12, 2024
1 parent 1f3d246 commit ad114b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ This document outlines environment variables that can be used to customize behav
| `WORKFLOW_GC_PERIOD` | `time.Duration` | `5m` | The periodicity for GC of workflows. |
| `SEMAPHORE_NOTIFY_DELAY` | `time.Duration` | `1s` | Tuning Delay when notifying semaphore waiters about availability in the semaphore |
| `WATCH_CONTROLLER_SEMAPHORE_CONFIGMAPS` | `bool` | `true` | Whether to watch the Controller's ConfigMap and semaphore ConfigMaps for run-time changes. When disabled, the Controller will only read these ConfigMaps once and will have to be manually restarted to pick up new changes. |
| `SKIP_WORKFLOW_DURATION_ESTIMATION` | `bool` | `false` | Whether to lookup resource usage from prior workflows to estimate usage for new workflows. |

CLI parameters of the Controller can be specified as environment variables with the `ARGO_` prefix.
For example:
Expand Down
8 changes: 8 additions & 0 deletions workflow/controller/estimation/estimator_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/argoproj/argo-workflows/v3/persist/sqldb"
wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo-workflows/v3/util/env"
"github.com/argoproj/argo-workflows/v3/workflow/common"
"github.com/argoproj/argo-workflows/v3/workflow/controller/indexes"
"github.com/argoproj/argo-workflows/v3/workflow/hydrator"
Expand All @@ -28,12 +29,19 @@ type estimatorFactory struct {

var _ EstimatorFactory = &estimatorFactory{}

var (
skipWorkflowDurationEstimation = env.LookupEnvStringOr("SKIP_WORKFLOW_DURATION_ESTIMATION", "false")
)

func NewEstimatorFactory(wfInformer cache.SharedIndexInformer, hydrator hydrator.Interface, wfArchive sqldb.WorkflowArchive) EstimatorFactory {
return &estimatorFactory{wfInformer, hydrator, wfArchive}
}

func (f *estimatorFactory) NewEstimator(wf *wfv1.Workflow) (Estimator, error) {
defaultEstimator := &estimator{wf: wf}
if skipWorkflowDurationEstimation == "true" {
return defaultEstimator, nil
}
for labelName, indexName := range map[string]string{
common.LabelKeyWorkflowTemplate: indexes.WorkflowTemplateIndex,
common.LabelKeyClusterWorkflowTemplate: indexes.ClusterWorkflowTemplateIndex,
Expand Down

0 comments on commit ad114b0

Please sign in to comment.