diff --git a/cmd/server.go b/cmd/server.go index 7e7d1b22d8..de4ce52403 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -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" @@ -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{ @@ -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, diff --git a/runatlantis.io/docs/server-configuration.md b/runatlantis.io/docs/server-configuration.md index 78ff63b4b5..4a945e96a4 100644 --- a/runatlantis.io/docs/server-configuration.md +++ b/runatlantis.io/docs/server-configuration.md @@ -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 diff --git a/server/events/command_runner.go b/server/events/command_runner.go index 1c4f02505a..089f1f679c 100644 --- a/server/events/command_runner.go +++ b/server/events/command_runner.go @@ -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. @@ -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() diff --git a/server/server.go b/server/server.go index c348c2e90a..43a461c4fd 100644 --- a/server/server.go +++ b/server/server.go @@ -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{}, diff --git a/server/user_config.go b/server/user_config.go index 8064ca168a..5736d73b6a 100644 --- a/server/user_config.go +++ b/server/user_config.go @@ -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"`