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
c3829433
Commit
c3829433
authored
Feb 10, 2016
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #20726 from ingvagabund/jitter-sync-loops-in-kubelet
Auto commit by PR queue bot
parents
2fbd44c1
392fc666
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
pod_workers.go
pkg/kubelet/pod_workers.go
+11
-2
worker.go
pkg/kubelet/prober/worker.go
+7
-1
No files found.
pkg/kubelet/pod_workers.go
View file @
c3829433
...
@@ -28,6 +28,7 @@ import (
...
@@ -28,6 +28,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/util/queue"
"k8s.io/kubernetes/pkg/kubelet/util/queue"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/runtime"
"k8s.io/kubernetes/pkg/util/wait"
)
)
// PodWorkers is an abstract interface for testability.
// PodWorkers is an abstract interface for testability.
...
@@ -39,6 +40,14 @@ type PodWorkers interface {
...
@@ -39,6 +40,14 @@ type PodWorkers interface {
type
syncPodFnType
func
(
*
api
.
Pod
,
*
api
.
Pod
,
*
kubecontainer
.
PodStatus
,
kubetypes
.
SyncPodType
)
error
type
syncPodFnType
func
(
*
api
.
Pod
,
*
api
.
Pod
,
*
kubecontainer
.
PodStatus
,
kubetypes
.
SyncPodType
)
error
const
(
// jitter factor for resyncInterval
workerResyncIntervalJitterFactor
=
0.5
// jitter factor for backOffPeriod
workerBackOffPeriodJitterFactor
=
0.5
)
type
podWorkers
struct
{
type
podWorkers
struct
{
// Protects all per worker fields.
// Protects all per worker fields.
podLock
sync
.
Mutex
podLock
sync
.
Mutex
...
@@ -209,10 +218,10 @@ func (p *podWorkers) wrapUp(uid types.UID, syncErr error) {
...
@@ -209,10 +218,10 @@ func (p *podWorkers) wrapUp(uid types.UID, syncErr error) {
switch
{
switch
{
case
syncErr
==
nil
:
case
syncErr
==
nil
:
// No error; requeue at the regular resync interval.
// No error; requeue at the regular resync interval.
p
.
workQueue
.
Enqueue
(
uid
,
p
.
resyncInterval
)
p
.
workQueue
.
Enqueue
(
uid
,
wait
.
Jitter
(
p
.
resyncInterval
,
workerResyncIntervalJitterFactor
)
)
default
:
default
:
// Error occurred during the sync; back off and then retry.
// Error occurred during the sync; back off and then retry.
p
.
workQueue
.
Enqueue
(
uid
,
p
.
backOffPeriod
)
p
.
workQueue
.
Enqueue
(
uid
,
wait
.
Jitter
(
p
.
backOffPeriod
,
workerBackOffPeriodJitterFactor
)
)
}
}
p
.
checkForUpdates
(
uid
)
p
.
checkForUpdates
(
uid
)
}
}
...
...
pkg/kubelet/prober/worker.go
View file @
c3829433
...
@@ -17,6 +17,7 @@ limitations under the License.
...
@@ -17,6 +17,7 @@ limitations under the License.
package
prober
package
prober
import
(
import
(
"math/rand"
"time"
"time"
"github.com/golang/glog"
"github.com/golang/glog"
...
@@ -93,7 +94,8 @@ func newWorker(
...
@@ -93,7 +94,8 @@ func newWorker(
// run periodically probes the container.
// run periodically probes the container.
func
(
w
*
worker
)
run
()
{
func
(
w
*
worker
)
run
()
{
probeTicker
:=
time
.
NewTicker
(
time
.
Duration
(
w
.
spec
.
PeriodSeconds
)
*
time
.
Second
)
probeTickerPeriod
:=
time
.
Duration
(
w
.
spec
.
PeriodSeconds
)
*
time
.
Second
probeTicker
:=
time
.
NewTicker
(
probeTickerPeriod
)
defer
func
()
{
defer
func
()
{
// Clean up.
// Clean up.
...
@@ -105,6 +107,10 @@ func (w *worker) run() {
...
@@ -105,6 +107,10 @@ func (w *worker) run() {
w
.
probeManager
.
removeWorker
(
w
.
pod
.
UID
,
w
.
container
.
Name
,
w
.
probeType
)
w
.
probeManager
.
removeWorker
(
w
.
pod
.
UID
,
w
.
container
.
Name
,
w
.
probeType
)
}()
}()
// If kubelet restarted the probes could be started in rapid succession.
// Let the worker wait for a random portion of tickerPeriod before probing.
time
.
Sleep
(
time
.
Duration
(
rand
.
Float64
()
*
float64
(
probeTickerPeriod
)))
probeLoop
:
probeLoop
:
for
w
.
doProbe
()
{
for
w
.
doProbe
()
{
// Wait for next probe tick.
// Wait for next probe tick.
...
...
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