Skip to content

Commit

Permalink
Merge pull request kubernetes#529 from justinsb/iam_sync_messaging
Browse files Browse the repository at this point in the history
Better messaging during IAM replication
  • Loading branch information
justinsb authored Sep 28, 2016
2 parents 5871b24 + a4d9e3c commit 6388a77
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions upup/pkg/fi/cloudup/awstasks/launchconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
"k8s.io/kops/upup/pkg/fi/cloudup/terraform"
"strings"
"time"
)

//go:generate fitask -type=LaunchConfiguration
Expand Down Expand Up @@ -255,18 +256,32 @@ func (_ *LaunchConfiguration) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *La
request.IamInstanceProfile = e.IAMInstanceProfile.Name
}

_, err = t.Cloud.Autoscaling().CreateLaunchConfiguration(request)
maxAttempts := 6
attempt := 0
for {
attempt++
_, err = t.Cloud.Autoscaling().CreateLaunchConfiguration(request)

if err == nil {
break
}

if err != nil {
if awsup.AWSErrorCode(err) == "ValidationError" {
message := awsup.AWSErrorMessage(err)
if strings.Contains(message, "not authorized") || strings.Contains(message, "Invalid IamInstance") {
// IAM instance profile creation is notoriously async
return fmt.Errorf("IAM instance profile not yet created/propagated")
if attempt == maxAttempts {
// IAM instance profile creation is notoriously async
return fmt.Errorf("IAM instance profile not yet created/propagated")
} else {
glog.Infof("Waiting for IAM to replicate")
glog.V(2).Infof("IAM error was %v", err)
time.Sleep(10 * time.Second)
continue
}
}
glog.V(4).Infof("ErrorCode=%q, Message=%q", awsup.AWSErrorCode(err), awsup.AWSErrorMessage(err))
return fmt.Errorf("error creating AutoscalingLaunchConfiguration: %v", err)
}
glog.V(4).Infof("ErrorCode=%q, Message=%q", awsup.AWSErrorCode(err), awsup.AWSErrorMessage(err))
return fmt.Errorf("error creating AutoscalingLaunchConfiguration: %v", err)
}

e.ID = fi.String(launchConfigurationName)
Expand Down

0 comments on commit 6388a77

Please sign in to comment.