Always resync after resyncInterval
This commit is contained in:
		| @@ -475,6 +475,7 @@ type Kubelet struct { | ||||
| 	rootDirectory  string | ||||
| 	podWorkers     PodWorkers | ||||
| 	resyncInterval time.Duration | ||||
| 	resyncTicker   *time.Ticker | ||||
| 	sourcesReady   SourcesReadyFn | ||||
| 	// sourcesSeen records the sources seen by kubelet. This set is not thread | ||||
| 	// safe and should only be access by the main kubelet syncloop goroutine. | ||||
| @@ -2010,6 +2011,7 @@ func (kl *Kubelet) canAdmitPod(pods []*api.Pod, pod *api.Pod) (bool, string, str | ||||
| // state every sync-frequency seconds. Never returns. | ||||
| func (kl *Kubelet) syncLoop(updates <-chan kubetypes.PodUpdate, handler SyncHandler) { | ||||
| 	glog.Info("Starting kubelet main sync loop.") | ||||
| 	kl.resyncTicker = time.NewTicker(kl.resyncInterval) | ||||
| 	var housekeepingTimestamp time.Time | ||||
| 	for { | ||||
| 		if !kl.containerRuntimeUp() { | ||||
| @@ -2073,7 +2075,7 @@ func (kl *Kubelet) syncLoopIteration(updates <-chan kubetypes.PodUpdate, handler | ||||
| 			// TODO: Do we want to support this? | ||||
| 			glog.Errorf("Kubelet does not support snapshot update") | ||||
| 		} | ||||
| 	case <-time.After(kl.resyncInterval): | ||||
| 	case <-kl.resyncTicker.C: | ||||
| 		// Periodically syncs all the pods and performs cleanup tasks. | ||||
| 		glog.V(4).Infof("SyncLoop (periodic sync)") | ||||
| 		handler.HandlePodSyncs(kl.podManager.GetPods()) | ||||
|   | ||||
| @@ -145,6 +145,7 @@ func newTestKubelet(t *testing.T) *TestKubelet { | ||||
| 	kubelet.backOff = util.NewBackOff(time.Second, time.Minute) | ||||
| 	kubelet.backOff.Clock = fakeClock | ||||
| 	kubelet.podKillingCh = make(chan *kubecontainer.Pod, 20) | ||||
| 	kubelet.resyncInterval = 10 * time.Second | ||||
| 	return &TestKubelet{kubelet, fakeRuntime, mockCadvisor, fakeKubeClient, fakeMirrorClient} | ||||
| } | ||||
|  | ||||
| @@ -332,6 +333,9 @@ func TestSyncLoopTimeUpdate(t *testing.T) { | ||||
| 		t.Errorf("Unexpected sync loop time: %s, expected 0", loopTime1) | ||||
| 	} | ||||
|  | ||||
| 	// Start sync ticker. | ||||
| 	kubelet.resyncTicker = time.NewTicker(time.Millisecond) | ||||
|  | ||||
| 	kubelet.syncLoopIteration(make(chan kubetypes.PodUpdate), kubelet) | ||||
| 	loopTime2 := kubelet.LatestLoopEntryTime() | ||||
| 	if loopTime2.IsZero() { | ||||
| @@ -350,9 +354,9 @@ func TestSyncLoopAbort(t *testing.T) { | ||||
| 	kubelet := testKubelet.kubelet | ||||
| 	kubelet.lastTimestampRuntimeUp = time.Now() | ||||
| 	kubelet.networkConfigured = true | ||||
| 	// The syncLoop waits on time.After(resyncInterval), set it really big so that we don't race for | ||||
| 	// the channel close | ||||
| 	kubelet.resyncInterval = time.Second * 30 | ||||
| 	// The syncLoop waits on the resyncTicker, so we stop it immediately to avoid a race. | ||||
| 	kubelet.resyncTicker = time.NewTicker(time.Second) | ||||
| 	kubelet.resyncTicker.Stop() | ||||
|  | ||||
| 	ch := make(chan kubetypes.PodUpdate) | ||||
| 	close(ch) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tim St. Clair
					Tim St. Clair