Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
be3fcd43
Commit
be3fcd43
authored
Dec 14, 2016
by
Jan Safranek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AWS: Add exponential backoff to createTags()
We should have something more reliable than 1 second sleep
parent
92e576e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
12 deletions
+24
-12
aws.go
pkg/cloudprovider/providers/aws/aws.go
+24
-12
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
be3fcd43
...
@@ -147,6 +147,15 @@ const (
...
@@ -147,6 +147,15 @@ const (
volumeAttachmentStatusInitialDelay
=
10
*
time
.
Second
volumeAttachmentStatusInitialDelay
=
10
*
time
.
Second
volumeAttachmentStatusFactor
=
1.2
volumeAttachmentStatusFactor
=
1.2
volumeAttachmentStatusSteps
=
21
volumeAttachmentStatusSteps
=
21
// createTag* is configuration of exponential backoff for CreateTag call. We
// retry mainly because if we create an object, we cannot tag it until it is
// "fully created" (eventual consistency). Starting with 1 second, doubling
// it every step and taking 9 steps results in 255 second total waiting
// time.
createTagInitialDelay
=
1
*
time
.
Second
createTagFactor
=
2.0
createTagSteps
=
9
)
)
// Maps from backend protocol to ELB protocol
// Maps from backend protocol to ELB protocol
...
@@ -2241,30 +2250,33 @@ func (c *Cloud) createTags(resourceID string, tags map[string]string) error {
...
@@ -2241,30 +2250,33 @@ func (c *Cloud) createTags(resourceID string, tags map[string]string) error {
awsTags
=
append
(
awsTags
,
tag
)
awsTags
=
append
(
awsTags
,
tag
)
}
}
backoff
:=
wait
.
Backoff
{
Duration
:
createTagInitialDelay
,
Factor
:
createTagFactor
,
Steps
:
createTagSteps
,
}
request
:=
&
ec2
.
CreateTagsInput
{}
request
:=
&
ec2
.
CreateTagsInput
{}
request
.
Resources
=
[]
*
string
{
&
resourceID
}
request
.
Resources
=
[]
*
string
{
&
resourceID
}
request
.
Tags
=
awsTags
request
.
Tags
=
awsTags
// TODO: We really should do exponential backoff here
var
lastErr
error
attempt
:=
0
err
:=
wait
.
ExponentialBackoff
(
backoff
,
func
()
(
bool
,
error
)
{
maxAttempts
:=
60
for
{
_
,
err
:=
c
.
ec2
.
CreateTags
(
request
)
_
,
err
:=
c
.
ec2
.
CreateTags
(
request
)
if
err
==
nil
{
if
err
==
nil
{
return
nil
return
true
,
nil
}
}
// We could check that the error is retryable, but the error code changes based on what we are tagging
// We could check that the error is retryable, but the error code changes based on what we are tagging
// SecurityGroup: InvalidGroup.NotFound
// SecurityGroup: InvalidGroup.NotFound
attempt
++
if
attempt
>
maxAttempts
{
glog
.
Warningf
(
"Failed to create tags (too many attempts): %v"
,
err
)
return
err
}
glog
.
V
(
2
)
.
Infof
(
"Failed to create tags; will retry. Error was %v"
,
err
)
glog
.
V
(
2
)
.
Infof
(
"Failed to create tags; will retry. Error was %v"
,
err
)
time
.
Sleep
(
1
*
time
.
Second
)
lastErr
=
err
return
false
,
nil
})
if
err
==
wait
.
ErrWaitTimeout
{
// return real CreateTags error instead of timeout
err
=
lastErr
}
}
return
err
}
}
// Finds the value for a given tag.
// Finds the value for a given tag.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment