Skip to content

Commit 7aa7062

Browse files
committed
Address feedback
1 parent dbc4734 commit 7aa7062

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

pkg/kubelet/kubelet.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ const (
184184
eventedPlegRelistPeriod = time.Second * 300
185185
eventedPlegRelistThreshold = time.Minute * 10
186186
eventedPlegMaxStreamRetries = 5
187+
// Evented PLEG needs to update the global timestamp of the cache as frequently as Generic PLEG relisting
188+
// in order to wake up pod workers that get stuck in cache.GetNewerThan().
189+
eventedPlegCacheUpdatePeriod = genericPlegRelistPeriod
187190

188191
// backOffPeriod is the period to back off when pod syncing results in an
189192
// error. It is also used as the base period for the exponential backoff
@@ -736,7 +739,7 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
736739
RelistThreshold: genericPlegRelistThreshold,
737740
}
738741
klet.eventedPleg, err = pleg.NewEventedPLEG(klet.containerRuntime, klet.runtimeService, eventChannel,
739-
klet.podCache, klet.pleg, eventedPlegMaxStreamRetries, eventedRelistDuration, clock.RealClock{})
742+
klet.podCache, klet.pleg, eventedPlegMaxStreamRetries, eventedRelistDuration, clock.RealClock{}, eventedPlegCacheUpdatePeriod)
740743
if err != nil {
741744
return nil, err
742745
}

pkg/kubelet/pleg/evented.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ import (
3131
"k8s.io/utils/clock"
3232
)
3333

34-
// The frequency with which global timestamp of the cache is to
35-
// is to be updated periodically. If pod workers get stuck at cache.GetNewerThan
36-
// call, after this period it will be unblocked.
37-
const globalCacheUpdatePeriod = 1 * time.Second
38-
3934
var (
4035
eventedPLEGUsage = false
4136
eventedPLEGUsageMu = sync.RWMutex{}
@@ -76,6 +71,10 @@ type EventedPLEG struct {
7671
eventedPlegMaxStreamRetries int
7772
// Indicates relisting related parameters
7873
relistDuration *RelistDuration
74+
// The frequency with which global timestamp of the cache is to
75+
// is to be updated periodically. If pod workers get stuck at cache.GetNewerThan
76+
// call, after this period it will be unblocked.
77+
globalCacheUpdatePeriod time.Duration
7978
// Stop the Evented PLEG by closing the channel.
8079
stopCh chan struct{}
8180
// Stops the periodic update of the cache global timestamp.
@@ -87,7 +86,7 @@ type EventedPLEG struct {
8786
// NewEventedPLEG instantiates a new EventedPLEG object and return it.
8887
func NewEventedPLEG(runtime kubecontainer.Runtime, runtimeService internalapi.RuntimeService, eventChannel chan *PodLifecycleEvent,
8988
cache kubecontainer.Cache, genericPleg PodLifecycleEventGenerator, eventedPlegMaxStreamRetries int,
90-
relistDuration *RelistDuration, clock clock.Clock) (PodLifecycleEventGenerator, error) {
89+
relistDuration *RelistDuration, clock clock.Clock, cacheUpdatePeriod time.Duration) (PodLifecycleEventGenerator, error) {
9190
handler, ok := genericPleg.(podLifecycleEventGeneratorHandler)
9291
if !ok {
9392
return nil, fmt.Errorf("%v doesn't implement podLifecycleEventGeneratorHandler interface", genericPleg)
@@ -101,6 +100,7 @@ func NewEventedPLEG(runtime kubecontainer.Runtime, runtimeService internalapi.Ru
101100
eventedPlegMaxStreamRetries: eventedPlegMaxStreamRetries,
102101
relistDuration: relistDuration,
103102
clock: clock,
103+
globalCacheUpdatePeriod: cacheUpdatePeriod,
104104
}, nil
105105
}
106106

@@ -125,7 +125,7 @@ func (e *EventedPLEG) Start() {
125125
e.stopCh = make(chan struct{})
126126
e.stopCacheUpdateCh = make(chan struct{})
127127
go wait.Until(e.watchEventsChannel, 0, e.stopCh)
128-
go wait.Until(e.updateGlobalCache, globalCacheUpdatePeriod, e.stopCacheUpdateCh)
128+
go wait.Until(e.updateGlobalCache, e.globalCacheUpdatePeriod, e.stopCacheUpdateCh)
129129
}
130130

131131
// Stop stops the Evented PLEG

0 commit comments

Comments
 (0)