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
3eaf362f
Commit
3eaf362f
authored
Jan 13, 2015
by
Alex Robinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch the client event recorder from exponential backoff to one random
sleep on the first failed request followed by a constant amount on all subsequent consecutive failed requests.
parent
be6b1cf0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
16 deletions
+13
-16
event.go
pkg/client/record/event.go
+10
-11
event_test.go
pkg/client/record/event_test.go
+3
-5
No files found.
pkg/client/record/event.go
View file @
3eaf362f
...
...
@@ -18,7 +18,7 @@ package record
import
(
"fmt"
"math"
"math
/rand
"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
...
...
@@ -26,19 +26,14 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/runtime"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/wait"
"github.com/GoogleCloudPlatform/kubernetes/pkg/watch"
"github.com/golang/glog"
)
const
maxTriesPerEvent
=
1
0
const
maxTriesPerEvent
=
1
2
var
(
minSleep
=
float64
(
1
*
time
.
Second
)
maxSleep
=
float64
(
15
*
time
.
Second
)
backoffExp
=
1.5
)
var
sleepDuration
=
time
.
Duration
(
10
*
time
.
Second
)
// EventRecorder knows how to store events (client.Client implements it.)
// EventRecorder must respect the namespace that will be embedded in 'event'.
...
...
@@ -70,9 +65,13 @@ func StartRecording(recorder EventRecorder, source api.EventSource) watch.Interf
glog
.
Errorf
(
"Unable to write event '%#v' (retry limit exceeded!)"
,
event
)
break
}
sleepDuration
:=
time
.
Duration
(
math
.
Min
(
maxSleep
,
minSleep
*
math
.
Pow
(
backoffExp
,
float64
(
tries
-
1
))))
time
.
Sleep
(
wait
.
Jitter
(
sleepDuration
,
0.5
))
// Randomize the first sleep so that various clients won't all be
// synced up if the master goes down.
if
tries
==
1
{
time
.
Sleep
(
time
.
Duration
(
float64
(
sleepDuration
)
*
rand
.
Float64
()))
}
else
{
time
.
Sleep
(
sleepDuration
)
}
}
})
}
...
...
pkg/client/record/event_test.go
View file @
3eaf362f
...
...
@@ -22,7 +22,6 @@ import (
"strconv"
"strings"
"testing"
"time"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
...
...
@@ -33,8 +32,7 @@ import (
func
init
()
{
// Don't bother sleeping between retries.
minSleep
=
0
maxSleep
=
0
sleepDuration
=
0
}
type
testEventRecorder
struct
{
...
...
@@ -195,12 +193,12 @@ func TestWriteEventError(t *testing.T) {
},
"retry1"
:
{
timesToSendError
:
1000
,
attemptsWanted
:
1
0
,
attemptsWanted
:
1
2
,
err
:
&
errors
.
UnexpectedObjectError
{},
},
"retry2"
:
{
timesToSendError
:
1000
,
attemptsWanted
:
1
0
,
attemptsWanted
:
1
2
,
err
:
fmt
.
Errorf
(
"A weird error"
),
},
"succeedEventually"
:
{
...
...
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