diff --git a/pkg/scheduler/framework/plugins/podtopologyspread/plugin.go b/pkg/scheduler/framework/plugins/podtopologyspread/plugin.go index 29ad4187bb4..c96db37d025 100644 --- a/pkg/scheduler/framework/plugins/podtopologyspread/plugin.go +++ b/pkg/scheduler/framework/plugins/podtopologyspread/plugin.go @@ -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. - if originalPod != nil { - if podLabelsMatchSpreadConstraints(constraints, originalPod.Labels) { + if modifiedPod != nil { + if podLabelsMatchSpreadConstraints(constraints, modifiedPod.Labels) { 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 } 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 } // 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", - "pod", klog.KObj(pod), "deletedPod", klog.KObj(modifiedPod)) + "pod", klog.KObj(pod), "deletedPod", klog.KObj(originalPod)) return framework.Queue, nil } 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 }