Change:
Currently the scheduler by default spreads the pods of a deployment based on a hard-coded . We recently a pod object api (pod.Spec.TopologySpreadConstraints) that allows specifying spread behavior at the workload level. For pods that specify topology spread constraints, the default spreading behavior should not apply. /sig scheduling /cc
I can fix this behavior, can you assign it to me?
/assign sure, lets wait for feedback first.
sure, thanks
I agree. Having the default spreading run would just water down the score given by the constraints. Other than that, this would just be a temporary fix until is finalized

Discussion:
return s } <ins> // skipDefaultPodTopologySpread returns true if the pod's TopologySpreadConstraints are specified. func skipDefaultPodTopologySpread(pod *v1.Pod) bool { return len(pod.Spec.TopologySpreadConstraints) != 0 } </ins> // Score invoked at the Score extension point. // The "score" returned in this function is the matching number of pods on the `nodeName`, // it is normalized later. func (pl *DefaultPodTopologySpread) Score(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (int64, *framework.Status) { <ins> if skipDefaultPodTopologySpread(pod) { return 0, nil } </ins> c, err := state.Read(postFilterStateKey) if err != nil { return 0, framework.NewStatus(framework.Error, fmt.Sprintf("Error reading %q from cycleState: %v", postFilterStateKey, err))

// where zone information is included on the nodes, it favors nodes // in zones with fewer existing matching pods. func (pl *DefaultPodTopologySpread) NormalizeScore(ctx context.Context, state *framework.CycleState, pod *v1.Pod, scores framework.NodeScoreList) *framework.Status { <ins> if skipDefaultPodTopologySpread(pod) { return nil } </ins> countsByZone := make(map[string]int64, 10) maxCountByZone := int64(0) maxCountByNodeName := int64(0)

expectedList: []framework.NodeScore{{Name: "machine1", Score: 0}, {Name: "machine2", Score: 50}}, name:         "Another stateful set with partial pod label matches", }, <ins> { pod: &v1.Pod{ ObjectMeta: metav1.ObjectMeta{ Labels:          labels1, OwnerReferences: controllerRef("StatefulSet", "name", "abc123"), }, Spec: v1.PodSpec{ TopologySpreadConstraints: []v1.TopologySpreadConstraint{ { MaxSkew:           1, TopologyKey:       "foo", WhenUnsatisfiable: v1.DoNotSchedule, }, }, }, }, pods: []*v1.Pod{ {Spec: zone1Spec, ObjectMeta: metav1.ObjectMeta{Labels: labels2, OwnerReferences: controllerRef("StatefulSet", "name", "abc123")}}, {Spec: zone1Spec, ObjectMeta: metav1.ObjectMeta{Labels: labels1, OwnerReferences: controllerRef("StatefulSet", "name", "abc123")}}, {Spec: zone2Spec, ObjectMeta: metav1.ObjectMeta{Labels: labels1, OwnerReferences: controllerRef("StatefulSet", "name", "abc123")}}, }, nodes:        []string{"machine1", "machine2"}, sss:          []*apps.StatefulSet{{Spec: apps.StatefulSetSpec{Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"baz": "blah"}}}}}, expectedList: []framework.NodeScore{{Name: "machine1", Score: 0}, {Name: "machine2", Score: 0}}, name:         "Another stateful set with TopologySpreadConstraints set in pod", }, </ins> } for _, test := range tests {