Increase timeout for IAM instance propagation

From 1 minute -> 5 minutes

Should help with issue #591
This commit is contained in:
Justin Santa Barbara 2016-10-18 02:15:31 -04:00
parent fd8cf63b02
commit dfb2a40dd5
1 changed files with 5 additions and 3 deletions

View File

@ -30,6 +30,9 @@ import (
"time" "time"
) )
const IAMPropagationRetryAttempts = 30
const IAMPropagationRetryInterval = 10 * time.Second
//go:generate fitask -type=LaunchConfiguration //go:generate fitask -type=LaunchConfiguration
type LaunchConfiguration struct { type LaunchConfiguration struct {
Name *string Name *string
@ -272,7 +275,6 @@ func (_ *LaunchConfiguration) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *La
request.IamInstanceProfile = e.IAMInstanceProfile.Name request.IamInstanceProfile = e.IAMInstanceProfile.Name
} }
maxAttempts := 6
attempt := 0 attempt := 0
for { for {
attempt++ attempt++
@ -285,13 +287,13 @@ func (_ *LaunchConfiguration) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *La
if awsup.AWSErrorCode(err) == "ValidationError" { if awsup.AWSErrorCode(err) == "ValidationError" {
message := awsup.AWSErrorMessage(err) message := awsup.AWSErrorMessage(err)
if strings.Contains(message, "not authorized") || strings.Contains(message, "Invalid IamInstance") { if strings.Contains(message, "not authorized") || strings.Contains(message, "Invalid IamInstance") {
if attempt == maxAttempts { if attempt == IAMPropagationRetryAttempts {
// IAM instance profile creation is notoriously async // IAM instance profile creation is notoriously async
return fmt.Errorf("IAM instance profile not yet created/propagated") return fmt.Errorf("IAM instance profile not yet created/propagated")
} else { } else {
glog.Infof("Waiting for IAM to replicate") glog.Infof("Waiting for IAM to replicate")
glog.V(2).Infof("IAM error was %v", err) glog.V(2).Infof("IAM error was %v", err)
time.Sleep(10 * time.Second) time.Sleep(IAMPropagationRetryInterval)
continue continue
} }
} }