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
8123a9ac
Commit
8123a9ac
authored
Aug 31, 2018
by
Shyam Jeedigunta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use random backoff for retries in cloud-cidr-allocator
parent
ff46c0fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
cloud_cidr_allocator.go
pkg/controller/nodeipam/ipam/cloud_cidr_allocator.go
+3
-2
cloud_cidr_allocator_test.go
pkg/controller/nodeipam/ipam/cloud_cidr_allocator_test.go
+5
-1
No files found.
pkg/controller/nodeipam/ipam/cloud_cidr_allocator.go
View file @
8123a9ac
...
@@ -18,6 +18,7 @@ package ipam
...
@@ -18,6 +18,7 @@ package ipam
import
(
import
(
"fmt"
"fmt"
"math/rand"
"net"
"net"
"sync"
"sync"
"time"
"time"
...
@@ -211,9 +212,9 @@ func nodeUpdateRetryTimeout(count int) time.Duration {
...
@@ -211,9 +212,9 @@ func nodeUpdateRetryTimeout(count int) time.Duration {
timeout
*=
2
timeout
*=
2
}
}
if
timeout
>
maxUpdateRetryTimeout
{
if
timeout
>
maxUpdateRetryTimeout
{
return
maxUpdateRetryTimeout
timeout
=
maxUpdateRetryTimeout
}
}
return
time
out
return
time
.
Duration
(
timeout
.
Nanoseconds
()
/
2
+
rand
.
Int63n
(
timeout
.
Nanoseconds
()))
}
}
func
(
ca
*
cloudCIDRAllocator
)
removeNodeFromProcessing
(
nodeName
string
)
{
func
(
ca
*
cloudCIDRAllocator
)
removeNodeFromProcessing
(
nodeName
string
)
{
...
...
pkg/controller/nodeipam/ipam/cloud_cidr_allocator_test.go
View file @
8123a9ac
...
@@ -59,6 +59,10 @@ func TestBoundedRetries(t *testing.T) {
...
@@ -59,6 +59,10 @@ func TestBoundedRetries(t *testing.T) {
}
}
}
}
func
withinExpectedRange
(
got
time
.
Duration
,
expected
time
.
Duration
)
bool
{
return
got
>=
expected
/
2
&&
got
<=
3
*
expected
/
2
}
func
TestNodeUpdateRetryTimeout
(
t
*
testing
.
T
)
{
func
TestNodeUpdateRetryTimeout
(
t
*
testing
.
T
)
{
for
_
,
tc
:=
range
[]
struct
{
for
_
,
tc
:=
range
[]
struct
{
count
int
count
int
...
@@ -71,7 +75,7 @@ func TestNodeUpdateRetryTimeout(t *testing.T) {
...
@@ -71,7 +75,7 @@ func TestNodeUpdateRetryTimeout(t *testing.T) {
{
count
:
50
,
want
:
5000
*
time
.
Millisecond
},
{
count
:
50
,
want
:
5000
*
time
.
Millisecond
},
}
{
}
{
t
.
Run
(
fmt
.
Sprintf
(
"count %d"
,
tc
.
count
),
func
(
t
*
testing
.
T
)
{
t
.
Run
(
fmt
.
Sprintf
(
"count %d"
,
tc
.
count
),
func
(
t
*
testing
.
T
)
{
if
got
:=
nodeUpdateRetryTimeout
(
tc
.
count
);
got
!=
tc
.
want
{
if
got
:=
nodeUpdateRetryTimeout
(
tc
.
count
);
!
withinExpectedRange
(
got
,
tc
.
want
)
{
t
.
Errorf
(
"nodeUpdateRetryTimeout(tc.count) = %v; want %v"
,
got
,
tc
.
want
)
t
.
Errorf
(
"nodeUpdateRetryTimeout(tc.count) = %v; want %v"
,
got
,
tc
.
want
)
}
}
})
})
...
...
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