Start using reason cache in kubelet

This commit is contained in:
Random-Liu
2016-01-12 13:28:00 -08:00
parent 123fec8a72
commit e9dceb36e9
2 changed files with 8 additions and 2 deletions

View File

@@ -441,6 +441,7 @@ func NewMainKubelet(
return nil, err return nil, err
} }
klet.runtimeCache = runtimeCache klet.runtimeCache = runtimeCache
klet.reasonCache = NewReasonCache()
klet.workQueue = queue.NewBasicWorkQueue() klet.workQueue = queue.NewBasicWorkQueue()
klet.podWorkers = newPodWorkers(runtimeCache, klet.syncPod, recorder, klet.workQueue, klet.resyncInterval, backOffPeriod, klet.podCache) klet.podWorkers = newPodWorkers(runtimeCache, klet.syncPod, recorder, klet.workQueue, klet.resyncInterval, backOffPeriod, klet.podCache)
@@ -563,6 +564,10 @@ type Kubelet struct {
// Container runtime. // Container runtime.
containerRuntime kubecontainer.Runtime containerRuntime kubecontainer.Runtime
// reasonCache caches the failure reason of the last creation of all containers, which is
// used for generating ContainerStatus.
reasonCache *ReasonCache
// nodeStatusUpdateFrequency specifies how often kubelet posts node status to master. // nodeStatusUpdateFrequency specifies how often kubelet posts node status to master.
// Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod // Note: be cautious when changing the constant, it must work with nodeMonitorGracePeriod
// in nodecontroller. There are several constraints: // in nodecontroller. There are several constraints:
@@ -1676,8 +1681,8 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
} }
result := kl.containerRuntime.SyncPod(pod, apiPodStatus, podStatus, pullSecrets, kl.backOff) result := kl.containerRuntime.SyncPod(pod, apiPodStatus, podStatus, pullSecrets, kl.backOff)
err = result.Error() kl.reasonCache.Update(pod.UID, result)
if err != nil { if err = result.Error(); err != nil {
return err return err
} }

View File

@@ -148,6 +148,7 @@ func newTestKubelet(t *testing.T) *TestKubelet {
kubelet.containerRuntime = fakeRuntime kubelet.containerRuntime = fakeRuntime
kubelet.runtimeCache = kubecontainer.NewFakeRuntimeCache(kubelet.containerRuntime) kubelet.runtimeCache = kubecontainer.NewFakeRuntimeCache(kubelet.containerRuntime)
kubelet.reasonCache = NewReasonCache()
kubelet.podWorkers = &fakePodWorkers{ kubelet.podWorkers = &fakePodWorkers{
syncPodFn: kubelet.syncPod, syncPodFn: kubelet.syncPod,
runtimeCache: kubelet.runtimeCache, runtimeCache: kubelet.runtimeCache,