diff --git a/CHANGELOG.md b/CHANGELOG.md index f95b6dee974..2411321208f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## v2.0.0-alpha.18 [unreleased] ### Features +1. [15110](https://github.com/influxdata/influxdb/pull/15110): Adds ability to set the default concurrency for tasks with an environment variable called DEFAULT_CONCURRENCY ### UI Improvements diff --git a/task/backend/scheduler.go b/task/backend/scheduler.go index 6870bd7b3d1..b513c16591a 100644 --- a/task/backend/scheduler.go +++ b/task/backend/scheduler.go @@ -6,6 +6,8 @@ import ( "errors" "fmt" "math" + "os" + "strconv" "sync" "sync/atomic" "time" @@ -469,6 +471,16 @@ func newTaskScheduler( return nil, err } maxC := defaultConcurrency + + // if an environment variable for default concurrency is set, use this value + // this will be overwritten if the Flux script for the task has a concurrency set + if envConcurrency := os.Getenv("DEFAULT_CONCURRENCY"); envConcurrency != "" { + c, err := strconv.Atoi(envConcurrency) + if err == nil { + maxC = c + } + } + if opt.Concurrency != nil { maxC = int(*opt.Concurrency) }