Skip to content

Commit e9d467b

Browse files
committed
Add default list of retryable errors and errors requiring init.
1 parent fd9a6ef commit e9d467b

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

options/auto_retry_options.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package options
2+
3+
const DEFAULT_MAX_RETRY_ATTEMPTS = 3
4+
const DEFAULT_SLEEP = 5
5+
6+
var RETRYABLE_ERRORS = []string{
7+
".*Failed to load state.*tcp.*timeout.*",
8+
".*Failed to load backend.*TLS handshake timeout.*",
9+
".*Creating metric alarm failed.*request to update this alarm is in progress.*",
10+
".*Error installing provider.*TLS handshake timeout.*",
11+
}
12+
13+
var ERRORS_REQUIRING_INIT = []string{
14+
".*Failed to load state.*tcp.*timeout.*",
15+
".*Failed to load backend.*TLS handshake timeout.*",
16+
".*Creating metric alarm failed.*request to update this alarm is in progress.*",
17+
".*Error installing provider.*TLS handshake timeout.*",
18+
}

options/options.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ var TERRAFORM_COMMANDS_WITH_SUBCOMMAND = []string{
1919
}
2020

2121
const DEFAULT_MAX_FOLDERS_TO_CHECK = 100
22-
const DEFAULT_MAX_RETRY_ATTEMPTS = 3
23-
const DEFAULT_SLEEP = 5
2422

2523
const TerragruntCacheDir = ".terragrunt-cache"
2624

@@ -91,6 +89,12 @@ type TerragruntOptions struct {
9189
// Sleep is the duration in seconds to wait before retrying
9290
Sleep int
9391

92+
// RetryableErrors is an array of regular expressions with RE2 syntax (https://github.com/google/re2/wiki/Syntax) that qualify for retrying
93+
RetryableErrors []string
94+
95+
// ErrorsRequiringInit is an array of regular expressions with RE2 syntax (https://github.com/google/re2/wiki/Syntax) that qualify for re-running init
96+
ErrorsRequiringInit []string
97+
9498
// Unix-style glob of directories to exclude when running *-all commands
9599
ExcludeDirs []string
96100

@@ -131,6 +135,8 @@ func NewTerragruntOptions(terragruntConfigPath string) (*TerragruntOptions, erro
131135
AutoRetry: true,
132136
MaxRetryAttempts: DEFAULT_MAX_RETRY_ATTEMPTS,
133137
Sleep: DEFAULT_SLEEP,
138+
RetryableErrors: util.CloneStringList(RETRYABLE_ERRORS),
139+
ErrorsRequiringInit: util.CloneStringList(ERRORS_REQUIRING_INIT),
134140
ExcludeDirs: []string{},
135141
RunTerragrunt: func(terragruntOptions *TerragruntOptions) error {
136142
return errors.WithStackTrace(RunTerragruntCommandNotSet)
@@ -195,6 +201,8 @@ func (terragruntOptions *TerragruntOptions) Clone(terragruntConfigPath string) *
195201
AutoRetry: terragruntOptions.AutoRetry,
196202
MaxRetryAttempts: terragruntOptions.MaxRetryAttempts,
197203
Sleep: terragruntOptions.Sleep,
204+
RetryableErrors: util.CloneStringList(terragruntOptions.RetryableErrors),
205+
ErrorsRequiringInit: util.CloneStringList(terragruntOptions.ErrorsRequiringInit),
198206
ExcludeDirs: terragruntOptions.ExcludeDirs,
199207
RunTerragrunt: terragruntOptions.RunTerragrunt,
200208
}

0 commit comments

Comments
 (0)