mirror of https://github.com/kubernetes/kops.git
cloudup: better retrying around resource tagging
This commit is contained in:
parent
c774777160
commit
9d6847ff49
|
|
@ -16,8 +16,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const MaxDescribeTagsAttempts = 10
|
const MaxDescribeTagsAttempts = 30
|
||||||
const MaxCreateTagsAttempts = 10
|
const MaxCreateTagsAttempts = 30
|
||||||
|
|
||||||
type AWSCloud struct {
|
type AWSCloud struct {
|
||||||
EC2 *ec2.EC2
|
EC2 *ec2.EC2
|
||||||
|
|
@ -76,8 +76,11 @@ func (c *AWSCloud) Tags() map[string]string {
|
||||||
func isTagsEventualConsistencyError(err error) bool {
|
func isTagsEventualConsistencyError(err error) bool {
|
||||||
if awsErr, ok := err.(awserr.Error); ok {
|
if awsErr, ok := err.(awserr.Error); ok {
|
||||||
switch awsErr.Code() {
|
switch awsErr.Code() {
|
||||||
case "InvalidInstanceID.NotFound":
|
case "InvalidInstanceID.NotFound", "InvalidRouteTableID.NotFound", "InvalidVpcID.NotFound", "InvalidGroup.NotFound":
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
default:
|
||||||
|
glog.Warningf("Uncategorized error in isTagsEventualConsistencyError: %v", awsErr.Code())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
@ -105,7 +108,7 @@ func (c *AWSCloud) GetTags(resourceId string) (map[string]string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Infof("will retry after encountering error gettings tags on %q: %v", resourceId, err)
|
glog.V(2).Infof("will retry after encountering error gettings tags on %q: %v", resourceId, err)
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,7 +155,7 @@ func (c *AWSCloud) CreateTags(resourceId string, tags map[string]string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
glog.V(2).Infof("will retry after encountering error creatings tags on %q: %v", resourceId, err)
|
glog.V(2).Infof("will retry after encountering error creatings tags on %q: %v", resourceId, err)
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue