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