mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #60246 from mtaufen/backoff-pleg
Automatic merge from submit-queue (batch tested with PRs 60157, 60337, 60246, 59714, 60467). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. backoff runtime errors in kubelet sync loop The runtime health check can race with PLEG's first relist, and this often results in an unnecessary 5 second wait during Kubelet bootstrap. This change aims to improve the performance. ```release-note NONE ```
This commit is contained in:
commit
729f691d74
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@ -1781,12 +1782,22 @@ func (kl *Kubelet) syncLoop(updates <-chan kubetypes.PodUpdate, handler SyncHand
|
|||||||
housekeepingTicker := time.NewTicker(housekeepingPeriod)
|
housekeepingTicker := time.NewTicker(housekeepingPeriod)
|
||||||
defer housekeepingTicker.Stop()
|
defer housekeepingTicker.Stop()
|
||||||
plegCh := kl.pleg.Watch()
|
plegCh := kl.pleg.Watch()
|
||||||
|
const (
|
||||||
|
base = 100 * time.Millisecond
|
||||||
|
max = 5 * time.Second
|
||||||
|
factor = 2
|
||||||
|
)
|
||||||
|
duration := base
|
||||||
for {
|
for {
|
||||||
if rs := kl.runtimeState.runtimeErrors(); len(rs) != 0 {
|
if rs := kl.runtimeState.runtimeErrors(); len(rs) != 0 {
|
||||||
glog.Infof("skipping pod synchronization - %v", rs)
|
glog.Infof("skipping pod synchronization - %v", rs)
|
||||||
time.Sleep(5 * time.Second)
|
// exponential backoff
|
||||||
|
time.Sleep(duration)
|
||||||
|
duration = time.Duration(math.Min(float64(max), factor*float64(duration)))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// reset backoff if we have a success
|
||||||
|
duration = base
|
||||||
|
|
||||||
kl.syncLoopMonitor.Store(kl.clock.Now())
|
kl.syncLoopMonitor.Store(kl.clock.Now())
|
||||||
if !kl.syncLoopIteration(updates, handler, syncTicker.C, housekeepingTicker.C, plegCh) {
|
if !kl.syncLoopIteration(updates, handler, syncTicker.C, housekeepingTicker.C, plegCh) {
|
||||||
|
Loading…
Reference in New Issue
Block a user