Merge pull request #31787 from gmarek/scheduledCondition
Automatic merge from submit-queue Make a scheduler predicates test resiliant to race for scheduledCondi… Fix #31341 @pwittrock - this fixes a P1 flake. FYI @mwielgus - I don't think that the race that caused this flake can impact cluster autoscaling, but you probably should know about it. cc @wojtek-t
This commit is contained in:
		@@ -119,13 +119,19 @@ func getPodsScheduled(pods *api.PodList) (scheduledPods, notScheduledPods []api.
 | 
				
			|||||||
		if !masterNodes.Has(pod.Spec.NodeName) {
 | 
							if !masterNodes.Has(pod.Spec.NodeName) {
 | 
				
			||||||
			if pod.Spec.NodeName != "" {
 | 
								if pod.Spec.NodeName != "" {
 | 
				
			||||||
				_, scheduledCondition := api.GetPodCondition(&pod.Status, api.PodScheduled)
 | 
									_, scheduledCondition := api.GetPodCondition(&pod.Status, api.PodScheduled)
 | 
				
			||||||
				Expect(scheduledCondition != nil).To(Equal(true))
 | 
									// We can't assume that the scheduledCondition is always set if Pod is assigned to Node,
 | 
				
			||||||
 | 
									// as e.g. DaemonController doesn't set it when assigning Pod to a Node. Currently
 | 
				
			||||||
 | 
									// Kubelet sets this condition when it gets a Pod without it, but if we were expecting
 | 
				
			||||||
 | 
									// that it would always be not nil, this would cause a rare race condition.
 | 
				
			||||||
 | 
									if scheduledCondition != nil {
 | 
				
			||||||
					Expect(scheduledCondition.Status).To(Equal(api.ConditionTrue))
 | 
										Expect(scheduledCondition.Status).To(Equal(api.ConditionTrue))
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				scheduledPods = append(scheduledPods, pod)
 | 
									scheduledPods = append(scheduledPods, pod)
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				_, scheduledCondition := api.GetPodCondition(&pod.Status, api.PodScheduled)
 | 
									_, scheduledCondition := api.GetPodCondition(&pod.Status, api.PodScheduled)
 | 
				
			||||||
				Expect(scheduledCondition != nil).To(Equal(true))
 | 
									if scheduledCondition != nil {
 | 
				
			||||||
					Expect(scheduledCondition.Status).To(Equal(api.ConditionFalse))
 | 
										Expect(scheduledCondition.Status).To(Equal(api.ConditionFalse))
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
				if scheduledCondition.Reason == "Unschedulable" {
 | 
									if scheduledCondition.Reason == "Unschedulable" {
 | 
				
			||||||
					notScheduledPods = append(notScheduledPods, pod)
 | 
										notScheduledPods = append(notScheduledPods, pod)
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user