Skip to content

Commit d121fed

Browse files
committed
Change weight assigned to podAntiAffinity to 100
The affinity weight ca be between 1 and 100 for each instance of the preferredDuringSchedulingIgnoredDuringExecution affinity type. When the scheduler finds nodes that meet all the other scheduling requirements of the Pod, the scheduler iterates through every preferred rule that the node satisfies and adds the value of the weight for that expression to a sum. To make the pods better spread bump the weight to the max. Still the anti affinty is "this Pod should not run in an X if that X is already running one or more Pods that meet rule Y", which means if there are less nodes, but enough resources, the pods get scheduled there. Related: https://issues.redhat.com/browse/OSPRH-8870 (cherry picked from commit c61e750)
1 parent 83ff4f7 commit d121fed

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

modules/common/affinity/affinity.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func DistributePods(
4848
// https://github.com/kubernetes/api/blob/master/core/v1/well_known_labels.go#L20
4949
TopologyKey: topologyKey,
5050
},
51-
Weight: 1,
51+
Weight: 100,
5252
},
5353
},
5454
},

modules/common/affinity/affinity_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var affinityObj = &corev1.Affinity{
4141
},
4242
TopologyKey: "ThisTopologyKey",
4343
},
44-
Weight: 1,
44+
Weight: 100,
4545
},
4646
},
4747
},

0 commit comments

Comments
 (0)