swap originalPod and modifiedPod to match the comments.

This commit is contained in:
nayihz 2024-01-06 19:00:36 +08:00
parent b5ba7bc4f5
commit edff1c3b2f

View File

@ -196,25 +196,25 @@ func (pl *PodTopologySpread) isSchedulableAfterPodChange(logger klog.Logger, pod
} }
// Pod is added. Return Queue when the added Pod has a label that matches with topologySpread's selector. // Pod is added. Return Queue when the added Pod has a label that matches with topologySpread's selector.
if originalPod != nil { if modifiedPod != nil {
if podLabelsMatchSpreadConstraints(constraints, originalPod.Labels) { if podLabelsMatchSpreadConstraints(constraints, modifiedPod.Labels) {
logger.V(5).Info("a scheduled pod was created and it matches with the pod's topology spread constraints", logger.V(5).Info("a scheduled pod was created and it matches with the pod's topology spread constraints",
"pod", klog.KObj(pod), "createdPod", klog.KObj(originalPod)) "pod", klog.KObj(pod), "createdPod", klog.KObj(modifiedPod))
return framework.Queue, nil return framework.Queue, nil
} }
logger.V(5).Info("a scheduled pod was created, but it doesn't matches with the pod's topology spread constraints", logger.V(5).Info("a scheduled pod was created, but it doesn't matches with the pod's topology spread constraints",
"pod", klog.KObj(pod), "createdPod", klog.KObj(originalPod)) "pod", klog.KObj(pod), "createdPod", klog.KObj(modifiedPod))
return framework.QueueSkip, nil return framework.QueueSkip, nil
} }
// Pod is deleted. Return Queue when the deleted Pod has a label that matches with topologySpread's selector. // Pod is deleted. Return Queue when the deleted Pod has a label that matches with topologySpread's selector.
if podLabelsMatchSpreadConstraints(constraints, modifiedPod.Labels) { if podLabelsMatchSpreadConstraints(constraints, originalPod.Labels) {
logger.V(5).Info("a scheduled pod which matches with the pod's topology spread constraints was deleted, and the pod may be schedulable now", logger.V(5).Info("a scheduled pod which matches with the pod's topology spread constraints was deleted, and the pod may be schedulable now",
"pod", klog.KObj(pod), "deletedPod", klog.KObj(modifiedPod)) "pod", klog.KObj(pod), "deletedPod", klog.KObj(originalPod))
return framework.Queue, nil return framework.Queue, nil
} }
logger.V(5).Info("a scheduled pod was deleted, but it's unrelated to the pod's topology spread constraints", logger.V(5).Info("a scheduled pod was deleted, but it's unrelated to the pod's topology spread constraints",
"pod", klog.KObj(pod), "deletedPod", klog.KObj(modifiedPod)) "pod", klog.KObj(pod), "deletedPod", klog.KObj(originalPod))
return framework.QueueSkip, nil return framework.QueueSkip, nil
} }