Keep PLEG interruptions in a separate interface
Signed-off-by: Harshal Patil <harpatil@redhat.com> Co-authored-by: Ed Bartosh <eduard.bartosh@intel.com>
This commit is contained in:
parent
c471f03ea3
commit
05f04f866e
@ -734,8 +734,11 @@ func NewMainKubelet(kubeCfg *kubeletconfiginternal.KubeletConfiguration,
|
||||
RelistPeriod: genericPlegRelistPeriod,
|
||||
RelistThreshold: genericPlegRelistThreshold,
|
||||
}
|
||||
klet.eventedPleg = pleg.NewEventedPLEG(klet.containerRuntime, klet.runtimeService, eventChannel,
|
||||
klet.eventedPleg, err = pleg.NewEventedPLEG(klet.containerRuntime, klet.runtimeService, eventChannel,
|
||||
klet.podCache, klet.pleg, eventedPlegMaxStreamRetries, eventedRelistDuration, clock.RealClock{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
genericRelistDuration := &pleg.RelistDuration{
|
||||
RelistPeriod: genericPlegRelistPeriod,
|
||||
|
@ -71,7 +71,7 @@ type EventedPLEG struct {
|
||||
// For testability.
|
||||
clock clock.Clock
|
||||
// GenericPLEG is used to force relist when required.
|
||||
genericPleg PodLifecycleEventGenerator
|
||||
genericPleg podLifecycleEventGeneratorHandler
|
||||
// The maximum number of retries when getting container events from the runtime.
|
||||
eventedPlegMaxStreamRetries int
|
||||
// Indicates relisting related parameters
|
||||
@ -87,17 +87,21 @@ type EventedPLEG struct {
|
||||
// NewEventedPLEG instantiates a new EventedPLEG object and return it.
|
||||
func NewEventedPLEG(runtime kubecontainer.Runtime, runtimeService internalapi.RuntimeService, eventChannel chan *PodLifecycleEvent,
|
||||
cache kubecontainer.Cache, genericPleg PodLifecycleEventGenerator, eventedPlegMaxStreamRetries int,
|
||||
relistDuration *RelistDuration, clock clock.Clock) PodLifecycleEventGenerator {
|
||||
relistDuration *RelistDuration, clock clock.Clock) (PodLifecycleEventGenerator, error) {
|
||||
handler, ok := genericPleg.(podLifecycleEventGeneratorHandler)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("%v doesn't implement podLifecycleEventGeneratorHandler interface", genericPleg)
|
||||
}
|
||||
return &EventedPLEG{
|
||||
runtime: runtime,
|
||||
runtimeService: runtimeService,
|
||||
eventChannel: eventChannel,
|
||||
cache: cache,
|
||||
genericPleg: genericPleg,
|
||||
genericPleg: handler,
|
||||
eventedPlegMaxStreamRetries: eventedPlegMaxStreamRetries,
|
||||
relistDuration: relistDuration,
|
||||
clock: clock,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Watch returns a channel from which the subscriber can receive PodLifecycleEvent events.
|
||||
|
@ -64,10 +64,16 @@ type PodLifecycleEvent struct {
|
||||
// PodLifecycleEventGenerator contains functions for generating pod life cycle events.
|
||||
type PodLifecycleEventGenerator interface {
|
||||
Start()
|
||||
Stop()
|
||||
Update(relistDuration *RelistDuration)
|
||||
Watch() chan *PodLifecycleEvent
|
||||
Healthy() (bool, error)
|
||||
Relist()
|
||||
UpdateCache(*kubecontainer.Pod, types.UID) (error, bool)
|
||||
}
|
||||
|
||||
// podLifecycleEventGeneratorHandler contains functions that are useful for different PLEGs
|
||||
// and need not be exposed to rest of the kubelet
|
||||
type podLifecycleEventGeneratorHandler interface {
|
||||
PodLifecycleEventGenerator
|
||||
Stop()
|
||||
Update(relistDuration *RelistDuration)
|
||||
Relist()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user