mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Fixes per review
Primarily go style issues; also a TODO that really exponential backoff is the correct policy for API call retries.
This commit is contained in:
parent
092d407a48
commit
23a190cd97
@ -1694,7 +1694,9 @@ func (s *AWSCloud) ensureSecurityGroup(name string, description string, vpcID st
|
|||||||
createResponse, err := s.ec2.CreateSecurityGroup(createRequest)
|
createResponse, err := s.ec2.CreateSecurityGroup(createRequest)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ignore := false
|
ignore := false
|
||||||
if awsError, ok := err.(awserr.Error); ok {
|
switch err.(type) {
|
||||||
|
case awserr.Error:
|
||||||
|
awsError := err.(awserr.Error)
|
||||||
if awsError.Code() == "InvalidGroup.Duplicate" && attempt < MaxReadThenCreateRetries {
|
if awsError.Code() == "InvalidGroup.Duplicate" && attempt < MaxReadThenCreateRetries {
|
||||||
glog.V(2).Infof("Got InvalidGroup.Duplicate while creating security group (race?); will retry")
|
glog.V(2).Infof("Got InvalidGroup.Duplicate while creating security group (race?); will retry")
|
||||||
ignore = true
|
ignore = true
|
||||||
@ -1725,8 +1727,7 @@ func (s *AWSCloud) ensureSecurityGroup(name string, description string, vpcID st
|
|||||||
tagRequest := &ec2.CreateTagsInput{}
|
tagRequest := &ec2.CreateTagsInput{}
|
||||||
tagRequest.Resources = []*string{&groupID}
|
tagRequest.Resources = []*string{&groupID}
|
||||||
tagRequest.Tags = tags
|
tagRequest.Tags = tags
|
||||||
_, err := s.createTags(tagRequest)
|
if _, err := s.createTags(tagRequest); err != nil {
|
||||||
if err != nil {
|
|
||||||
// Not clear how to recover fully from this; we're OK because we don't match on tags, but that is a little odd
|
// Not clear how to recover fully from this; we're OK because we don't match on tags, but that is a little odd
|
||||||
return "", fmt.Errorf("error tagging security group: %v", err)
|
return "", fmt.Errorf("error tagging security group: %v", err)
|
||||||
}
|
}
|
||||||
@ -1737,6 +1738,7 @@ func (s *AWSCloud) ensureSecurityGroup(name string, description string, vpcID st
|
|||||||
// We retry mainly because if we create an object, we cannot tag it until it is "fully created" (eventual consistency)
|
// We retry mainly because if we create an object, we cannot tag it until it is "fully created" (eventual consistency)
|
||||||
// The error code varies though (depending on what we are tagging), so we simply retry on all errors
|
// The error code varies though (depending on what we are tagging), so we simply retry on all errors
|
||||||
func (s *AWSCloud) createTags(request *ec2.CreateTagsInput) (*ec2.CreateTagsOutput, error) {
|
func (s *AWSCloud) createTags(request *ec2.CreateTagsInput) (*ec2.CreateTagsOutput, error) {
|
||||||
|
// TODO: We really should do exponential backoff here
|
||||||
attempt := 0
|
attempt := 0
|
||||||
maxAttempts := 60
|
maxAttempts := 60
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user