mirror of https://github.com/kubernetes/kops.git
Merge pull request #529 from justinsb/iam_sync_messaging
Better messaging during IAM replication
This commit is contained in:
commit
6388a77fd4
|
@ -11,6 +11,7 @@ import (
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
|
||||||
"k8s.io/kops/upup/pkg/fi/cloudup/terraform"
|
"k8s.io/kops/upup/pkg/fi/cloudup/terraform"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate fitask -type=LaunchConfiguration
|
//go:generate fitask -type=LaunchConfiguration
|
||||||
|
@ -255,19 +256,33 @@ func (_ *LaunchConfiguration) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *La
|
||||||
request.IamInstanceProfile = e.IAMInstanceProfile.Name
|
request.IamInstanceProfile = e.IAMInstanceProfile.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maxAttempts := 6
|
||||||
|
attempt := 0
|
||||||
|
for {
|
||||||
|
attempt++
|
||||||
_, err = t.Cloud.Autoscaling().CreateLaunchConfiguration(request)
|
_, err = t.Cloud.Autoscaling().CreateLaunchConfiguration(request)
|
||||||
|
|
||||||
if err != nil {
|
if err == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
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 {
|
||||||
// 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 {
|
||||||
|
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))
|
glog.V(4).Infof("ErrorCode=%q, Message=%q", awsup.AWSErrorCode(err), awsup.AWSErrorMessage(err))
|
||||||
return fmt.Errorf("error creating AutoscalingLaunchConfiguration: %v", err)
|
return fmt.Errorf("error creating AutoscalingLaunchConfiguration: %v", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
e.ID = fi.String(launchConfigurationName)
|
e.ID = fi.String(launchConfigurationName)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue