1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-26 05:14:13 +01:00

removepodsviolatingtopologyspreadconstraint: implement explicit constraints

This commit is contained in:
Amir Alavi
2023-06-03 18:58:18 -04:00
parent 5f0edb5f93
commit 7f2f6f2b16
14 changed files with 254 additions and 27 deletions

View File

@@ -118,6 +118,8 @@ func (d *RemovePodsViolatingTopologySpreadConstraint) Balance(ctx context.Contex
}
}
allowedConstraints := sets.New[v1.UnsatisfiableConstraintAction](d.args.Constraints...)
namespacedPods := podutil.GroupByNamespace(pods)
// 1. for each namespace...
@@ -131,8 +133,8 @@ func (d *RemovePodsViolatingTopologySpreadConstraint) Balance(ctx context.Contex
namespaceTopologySpreadConstraints := []v1.TopologySpreadConstraint{}
for _, pod := range namespacedPods[namespace] {
for _, constraint := range pod.Spec.TopologySpreadConstraints {
// Ignore soft topology constraints if they are not included
if constraint.WhenUnsatisfiable == v1.ScheduleAnyway && (d.args == nil || !d.args.IncludeSoftConstraints) {
// Ignore topology constraints if they are not included
if !allowedConstraints.Has(constraint.WhenUnsatisfiable) {
continue
}
// Need to check v1.TopologySpreadConstraint deepEquality because