@@ -19,9 +19,9 @@ package podtopologyspread
19
19
import (
20
20
"context"
21
21
"fmt"
22
- "reflect"
23
22
24
23
v1 "k8s.io/api/core/v1"
24
+ "k8s.io/apimachinery/pkg/api/equality"
25
25
"k8s.io/apimachinery/pkg/labels"
26
26
"k8s.io/apimachinery/pkg/runtime"
27
27
"k8s.io/client-go/informers"
@@ -139,10 +139,11 @@ func (pl *PodTopologySpread) setListers(factory informers.SharedInformerFactory)
139
139
func (pl * PodTopologySpread ) EventsToRegister (_ context.Context ) ([]framework.ClusterEventWithHint , error ) {
140
140
podActionType := framework .Add | framework .UpdatePodLabel | framework .Delete
141
141
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
144
143
// to determine whether a Pod's update makes the Pod schedulable or not.
145
144
// https://github.com/kubernetes/kubernetes/pull/122234
145
+ // (If not, the scheduling queue always retries the unschedulable Pods when they're updated.)
146
+ //
146
147
// The Pod rejected by this plugin can be schedulable when the Pod has a spread constraint with NodeTaintsPolicy:Honor
147
148
// and has got a new toleration.
148
149
// So, we add UpdatePodTolerations here only when QHint is enabled.
@@ -199,14 +200,14 @@ func (pl *PodTopologySpread) isSchedulableAfterPodChange(logger klog.Logger, pod
199
200
200
201
// Pod is modified. Return Queue when the label(s) matching topologySpread's selector is added, changed, or deleted.
201
202
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 ) {
203
204
// If any constraint has `NodeTaintsPolicy: Honor`, we can return Queue when the target Pod has got a new toleration.
204
205
logger .V (5 ).Info ("the unschedulable pod has got a new toleration, which could make it schedulable" ,
205
206
"pod" , klog .KObj (pod ), "modifiedPod" , klog .KObj (modifiedPod ))
206
207
return framework .Queue , nil
207
208
}
208
209
209
- if reflect .DeepEqual (modifiedPod .Labels , originalPod .Labels ) {
210
+ if equality . Semantic .DeepEqual (modifiedPod .Labels , originalPod .Labels ) {
210
211
logger .V (5 ).Info ("the pod's update doesn't include the label update, which doesn't make the target pod schedulable" ,
211
212
"pod" , klog .KObj (pod ), "modifiedPod" , klog .KObj (modifiedPod ))
212
213
return framework .QueueSkip , nil
0 commit comments