mirror of https://github.com/k3s-io/k3s
scheduler: fix flaky test TestPreemptionRaces
In some cases, an Update event with no "NominatedNode" present is received right after a node("NominatedNode") is reserved for this pod in memory. If we go updating (delete and add) it, it actually un-reserves the node since the newPod doesn't carry sped.status.nominatedNode. In this case, during this time other low-priority pods have chances to take space which was reserved for the nominatedPod.k3s-v1.15.3
parent
46a80259f6
commit
115fe94b6f
|
@ -772,7 +772,16 @@ func (npm *nominatedPodMap) delete(p *v1.Pod) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (npm *nominatedPodMap) update(oldPod, newPod *v1.Pod) {
|
func (npm *nominatedPodMap) update(oldPod, newPod *v1.Pod) {
|
||||||
// We update irrespective of the nominatedNodeName changed or not, to ensure
|
// In some cases, an Update event with no "NominatedNode" present is received right
|
||||||
|
// after a node("NominatedNode") is reserved for this pod in memory.
|
||||||
|
// If we go updating (delete and add) it, it actually un-reserves the node since
|
||||||
|
// the newPod doesn't carry Status.NominatedNodeName.
|
||||||
|
// In this case, during this time other low-priority pods have chances to take space which
|
||||||
|
// was reserved for the nominatedPod.
|
||||||
|
if len(oldPod.Status.NominatedNodeName) == 0 && len(newPod.Status.NominatedNodeName) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// We update once the nominatedNodeName gets changed, to ensure
|
||||||
// that pod pointer is updated.
|
// that pod pointer is updated.
|
||||||
npm.delete(oldPod)
|
npm.delete(oldPod)
|
||||||
npm.add(newPod, "")
|
npm.add(newPod, "")
|
||||||
|
|
Loading…
Reference in New Issue