Skip to content

Commit

Permalink
Added configurable parallelism pool size
Browse files Browse the repository at this point in the history
  • Loading branch information
dmattia committed Sep 3, 2020
1 parent cc55ba3 commit e19b845
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
30 changes: 18 additions & 12 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const (
GitlabWebhookSecretFlag = "gitlab-webhook-secret" // nolint: gosec
HidePrevPlanComments = "hide-prev-plan-comments"
LogLevelFlag = "log-level"
ParallelPoolSize = "parallel-pool-size"
AllowDraftPRs = "allow-draft-prs"
PortFlag = "port"
RepoConfigFlag = "repo-config"
Expand All @@ -87,18 +88,19 @@ const (
WriteGitCredsFlag = "write-git-creds"

// NOTE: Must manually set these as defaults in the setDefaults function.
DefaultADBasicUser = ""
DefaultADBasicPassword = ""
DefaultCheckoutStrategy = "branch"
DefaultBitbucketBaseURL = bitbucketcloud.BaseURL
DefaultDataDir = "~/.atlantis"
DefaultGHHostname = "github.com"
DefaultGitlabHostname = "gitlab.com"
DefaultLogLevel = "info"
DefaultPort = 4141
DefaultTFDownloadURL = "https://releases.hashicorp.com"
DefaultTFEHostname = "app.terraform.io"
DefaultVCSStatusName = "atlantis"
DefaultADBasicUser = ""
DefaultADBasicPassword = ""
DefaultCheckoutStrategy = "branch"
DefaultBitbucketBaseURL = bitbucketcloud.BaseURL
DefaultDataDir = "~/.atlantis"
DefaultGHHostname = "github.com"
DefaultGitlabHostname = "gitlab.com"
DefaultLogLevel = "info"
DefaultParallelPlansPoolSize = 15
DefaultPort = 4141
DefaultTFDownloadURL = "https://releases.hashicorp.com"
DefaultTFEHostname = "app.terraform.io"
DefaultVCSStatusName = "atlantis"
)

var stringFlags = map[string]stringFlag{
Expand Down Expand Up @@ -308,6 +310,10 @@ var boolFlags = map[string]boolFlag{
},
}
var intFlags = map[string]intFlag{
ParallelPlansPoolSize: {
description: "Max size of the wait group that runs parallel plans and applies (if enabled).",
defaultValue: DefaultParallelPlansPoolSize,
},
PortFlag: {
description: "Port to bind to.",
defaultValue: DefaultPort,
Expand Down
6 changes: 6 additions & 0 deletions runatlantis.io/docs/server-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ Values are chosen in this order:
```
Log level. Defaults to `info`.

* ### `--parallel-pool-size`
```bash
atlantis server --parallel-pool-size=100
```
Max size of the wait group that runs parallel plans and applies (if enabled). Defaults to `15`

* ### `--port`
```bash
atlantis server --port=8080
Expand Down
5 changes: 4 additions & 1 deletion server/events/command_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ type DefaultCommandRunner struct {
Logger logging.SimpleLogging
// AllowForkPRs controls whether we operate on pull requests from forks.
AllowForkPRs bool
// ParallelPoolSize controls the size of the wait group used to run
// parallel plans and applies (if enabled).
ParallelPoolSize int
// AllowForkPRsFlag is the name of the flag that controls fork PR's. We use
// this in our error message back to the user on a forked PR so they know
// how to enable this functionality.
Expand Down Expand Up @@ -400,7 +403,7 @@ func (c *DefaultCommandRunner) runProjectCmdsParallel(cmds []models.ProjectComma
var results []models.ProjectResult
mux := &sync.Mutex{}

wg := sizedwaitgroup.New(15)
wg := sizedwaitgroup.New(c.ParallelPlansPoolSize)
for _, pCmd := range cmds {
pCmd := pCmd
var execute func()
Expand Down
1 change: 1 addition & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) {
SilenceForkPRErrorsFlag: config.SilenceForkPRErrorsFlag,
SilenceVCSStatusNoPlans: userConfig.SilenceVCSStatusNoPlans,
DisableApplyAll: userConfig.DisableApplyAll,
ParallelPoolSize: userConfig.ParallelPoolSize,
ProjectCommandBuilder: &events.DefaultProjectCommandBuilder{
ParserValidator: validator,
ProjectFinder: &events.DefaultProjectFinder{},
Expand Down
1 change: 1 addition & 0 deletions server/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type UserConfig struct {
GitlabWebhookSecret string `mapstructure:"gitlab-webhook-secret"`
HidePrevPlanComments bool `mapstructure:"hide-prev-plan-comments"`
LogLevel string `mapstructure:"log-level"`
ParallelPoolSize int `mapstructure:"parallel-pool-size"`
PlanDrafts bool `mapstructure:"allow-draft-prs"`
Port int `mapstructure:"port"`
RepoConfig string `mapstructure:"repo-config"`
Expand Down

0 comments on commit e19b845

Please sign in to comment.