mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-01 02:38:12 +00:00 
			
		
		
		
	Fix:slow memory leak may be in kubelet podworkers.isWorking
This commit is contained in:
		| @@ -282,7 +282,8 @@ func (p *podWorkers) checkForUpdates(uid types.UID) { | ||||
| 		p.podUpdates[uid] <- workUpdate | ||||
| 		delete(p.lastUndeliveredWorkUpdate, uid) | ||||
| 	} else { | ||||
| 		p.isWorking[uid] = false | ||||
| 		// put this line in removeWorker may cause dead lock, so keep reset it here | ||||
| 		delete(p.isWorking, uid) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -241,6 +241,30 @@ func TestForgetNonExistingPodWorkers(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestIsWorkingClearedAfterForgetPodWorkers(t *testing.T) { | ||||
| 	podWorkers, _ := createPodWorkers() | ||||
|  | ||||
| 	numPods := 20 | ||||
| 	for i := 0; i < numPods; i++ { | ||||
| 		podWorkers.UpdatePod(&UpdatePodOptions{ | ||||
| 			Pod:        newPod(strconv.Itoa(i), "name"), | ||||
| 			UpdateType: kubetypes.SyncPodUpdate, | ||||
| 		}) | ||||
| 	} | ||||
| 	drainWorkers(podWorkers, numPods) | ||||
|  | ||||
| 	if len(podWorkers.podUpdates) != numPods { | ||||
| 		t.Errorf("Incorrect number of open channels %v", len(podWorkers.podUpdates)) | ||||
| 	} | ||||
| 	podWorkers.ForgetNonExistingPodWorkers(map[types.UID]sets.Empty{}) | ||||
| 	if len(podWorkers.podUpdates) != 0 { | ||||
| 		t.Errorf("Incorrect number of open channels %v", len(podWorkers.podUpdates)) | ||||
| 	} | ||||
| 	if len(podWorkers.isWorking) != 0 { | ||||
| 		t.Errorf("Incorrect number of isWorking %v", len(podWorkers.isWorking)) | ||||
| 	} | ||||
| } | ||||
|  | ||||
| type simpleFakeKubelet struct { | ||||
| 	pod       *v1.Pod | ||||
| 	mirrorPod *v1.Pod | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 KeZhang
					KeZhang