Skip to content

Commit f457777

Browse files
committed
chore: use DeepEqual from equality.Semantic instead of reflect
1 parent 9c3d4a6 commit f457777

File tree

1 file changed

+6
-5
lines changed
  • pkg/scheduler/framework/plugins/podtopologyspread

1 file changed

+6
-5
lines changed

pkg/scheduler/framework/plugins/podtopologyspread/plugin.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ package podtopologyspread
1919
import (
2020
"context"
2121
"fmt"
22-
"reflect"
2322

2423
v1 "k8s.io/api/core/v1"
24+
"k8s.io/apimachinery/pkg/api/equality"
2525
"k8s.io/apimachinery/pkg/labels"
2626
"k8s.io/apimachinery/pkg/runtime"
2727
"k8s.io/client-go/informers"
@@ -139,10 +139,11 @@ func (pl *PodTopologySpread) setListers(factory informers.SharedInformerFactory)
139139
func (pl *PodTopologySpread) EventsToRegister(_ context.Context) ([]framework.ClusterEventWithHint, error) {
140140
podActionType := framework.Add | framework.UpdatePodLabel | framework.Delete
141141
if pl.enableSchedulingQueueHint {
142-
// When the QueueingHint feature is enabled,
143-
// the scheduling queue uses Pod/Update Queueing Hint
142+
// When the QueueingHint feature is enabled, the scheduling queue uses Pod/Update Queueing Hint
144143
// to determine whether a Pod's update makes the Pod schedulable or not.
145144
// https://github.com/kubernetes/kubernetes/pull/122234
145+
// (If not, the scheduling queue always retries the unschedulable Pods when they're updated.)
146+
//
146147
// The Pod rejected by this plugin can be schedulable when the Pod has a spread constraint with NodeTaintsPolicy:Honor
147148
// and has got a new toleration.
148149
// So, we add UpdatePodTolerations here only when QHint is enabled.
@@ -199,14 +200,14 @@ func (pl *PodTopologySpread) isSchedulableAfterPodChange(logger klog.Logger, pod
199200

200201
// Pod is modified. Return Queue when the label(s) matching topologySpread's selector is added, changed, or deleted.
201202
if modifiedPod != nil && originalPod != nil {
202-
if pod.UID == modifiedPod.UID && !reflect.DeepEqual(modifiedPod.Spec.Tolerations, originalPod.Spec.Tolerations) && hasConstraintWithNodeTaintsPolicyHonor(constraints) {
203+
if pod.UID == modifiedPod.UID && !equality.Semantic.DeepEqual(modifiedPod.Spec.Tolerations, originalPod.Spec.Tolerations) && hasConstraintWithNodeTaintsPolicyHonor(constraints) {
203204
// If any constraint has `NodeTaintsPolicy: Honor`, we can return Queue when the target Pod has got a new toleration.
204205
logger.V(5).Info("the unschedulable pod has got a new toleration, which could make it schedulable",
205206
"pod", klog.KObj(pod), "modifiedPod", klog.KObj(modifiedPod))
206207
return framework.Queue, nil
207208
}
208209

209-
if reflect.DeepEqual(modifiedPod.Labels, originalPod.Labels) {
210+
if equality.Semantic.DeepEqual(modifiedPod.Labels, originalPod.Labels) {
210211
logger.V(5).Info("the pod's update doesn't include the label update, which doesn't make the target pod schedulable",
211212
"pod", klog.KObj(pod), "modifiedPod", klog.KObj(modifiedPod))
212213
return framework.QueueSkip, nil

0 commit comments

Comments
 (0)