diff --git a/cmd/server.go b/cmd/server.go index 37fa486382..a06c48f4e1 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -68,6 +68,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" @@ -101,6 +102,7 @@ const ( DefaultGHHostname = "github.com" DefaultGitlabHostname = "gitlab.com" DefaultLogLevel = "info" + DefaultParallelPoolSize = 15 DefaultPort = 4141 DefaultTFDownloadURL = "https://releases.hashicorp.com" DefaultTFEHostname = "app.terraform.io" @@ -331,6 +333,10 @@ var boolFlags = map[string]boolFlag{ }, } var intFlags = map[string]intFlag{ + ParallelPoolSize: { + description: "Max size of the wait group that runs parallel plans and applies (if enabled).", + defaultValue: DefaultParallelPoolSize, + }, PortFlag: { description: "Port to bind to.", defaultValue: DefaultPort, @@ -553,6 +559,9 @@ func (s *ServerCmd) setDefaults(c *server.UserConfig) { if c.LogLevel == "" { c.LogLevel = DefaultLogLevel } + if c.ParallelPoolSize == 0 { + c.ParallelPoolSize = DefaultParallelPoolSize + } if c.Port == 0 { c.Port = DefaultPort } diff --git a/cmd/server_test.go b/cmd/server_test.go index ea159a618f..30abc75ed4 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -80,6 +80,7 @@ var testFlags = map[string]interface{}{ LogLevelFlag: "debug", AllowDraftPRs: true, PortFlag: 8181, + ParallelPoolSize: 100, RepoAllowlistFlag: "github.com/runatlantis/atlantis", RequireApprovalFlag: true, RequireMergeableFlag: true, diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index dd100aa6df..81be5ac4c2 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -335,6 +335,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 diff --git a/server/events/command_runner.go b/server/events/command_runner.go index e0400054ed..0e1396b207 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -82,6 +82,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. @@ -404,7 +407,7 @@ func (c *DefaultCommandRunner) runProjectCmdsParallel(cmds []models.ProjectComma var results []models.ProjectResult mux := &sync.Mutex{} - wg := sizedwaitgroup.New(15) + wg := sizedwaitgroup.New(c.ParallelPoolSize) for _, pCmd := range cmds { pCmd := pCmd var execute func() diff --git a/server/server.go b/server/server.go index 5e7029c408..e4e39382bc 100644 --- a/server/server.go +++ b/server/server.go @@ -370,6 +370,7 @@ func NewServer(userConfig UserConfig, config Config) (*Server, error) { SilenceVCSStatusNoPlans: userConfig.SilenceVCSStatusNoPlans, DisableApplyAll: userConfig.DisableApplyAll, DisableAutoplan: userConfig.DisableAutoplan, + ParallelPoolSize: userConfig.ParallelPoolSize, ProjectCommandBuilder: &events.DefaultProjectCommandBuilder{ ParserValidator: validator, ProjectFinder: &events.DefaultProjectFinder{}, diff --git a/server/user_config.go b/server/user_config.go index c607e67dd2..54b66295e9 100644 --- a/server/user_config.go +++ b/server/user_config.go @@ -38,6 +38,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"`