Skip to content

Commit

Permalink
feat(tasks): use env variable for concurrency (#15110)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirieGray authored Sep 10, 2019
1 parent 901bf61 commit 21e14de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
12 changes: 12 additions & 0 deletions task/backend/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"errors"
"fmt"
"math"
"os"
"strconv"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 21e14de

Please sign in to comment.