@@ -28,6 +28,7 @@ import (
28
28
"k8s.io/kubernetes/pkg/kubelet/util/queue"
29
29
"k8s.io/kubernetes/pkg/types"
30
30
"k8s.io/kubernetes/pkg/util/runtime"
31
+ "k8s.io/kubernetes/pkg/util/wait"
31
32
)
32
33
33
34
// PodWorkers is an abstract interface for testability.
@@ -39,6 +40,14 @@ type PodWorkers interface {
39
40
40
41
type syncPodFnType func (* api.Pod , * api.Pod , * kubecontainer.PodStatus , kubetypes.SyncPodType ) error
41
42
43
+ const (
44
+ // jitter factor for resyncInterval
45
+ workerResyncIntervalJitterFactor = 0.5
46
+
47
+ // jitter factor for backOffPeriod
48
+ workerBackOffPeriodJitterFactor = 0.5
49
+ )
50
+
42
51
type podWorkers struct {
43
52
// Protects all per worker fields.
44
53
podLock sync.Mutex
@@ -209,10 +218,10 @@ func (p *podWorkers) wrapUp(uid types.UID, syncErr error) {
209
218
switch {
210
219
case syncErr == nil :
211
220
// No error; requeue at the regular resync interval.
212
- p .workQueue .Enqueue (uid , p .resyncInterval )
221
+ p .workQueue .Enqueue (uid , wait . Jitter ( p .resyncInterval , workerResyncIntervalJitterFactor ) )
213
222
default :
214
223
// Error occurred during the sync; back off and then retry.
215
- p .workQueue .Enqueue (uid , p .backOffPeriod )
224
+ p .workQueue .Enqueue (uid , wait . Jitter ( p .backOffPeriod , workerBackOffPeriodJitterFactor ) )
216
225
}
217
226
p .checkForUpdates (uid )
218
227
}
0 commit comments