mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-03 19:58:17 +00:00
feature(scheduler): more fine-grained QHints for podtopologyspread plugin
This commit is contained in:
@@ -805,28 +805,37 @@ func TestCoreResourceEnqueue(t *testing.T) {
|
||||
{
|
||||
name: "Pods with PodTopologySpread should be requeued when a Node is updated to have the topology label",
|
||||
initialNodes: []*v1.Node{
|
||||
st.MakeNode().Name("fake-node1").Label("node", "fake-node").Obj(),
|
||||
st.MakeNode().Name("fake-node2").Label("node", "fake-node").Obj(),
|
||||
st.MakeNode().Name("fake-node1").Label("node", "fake-node").Label("region", "fake-node").Label("service", "service-a").Obj(),
|
||||
st.MakeNode().Name("fake-node2").Label("node", "fake-node").Label("region", "fake-node").Label("service", "service-a").Obj(),
|
||||
},
|
||||
initialPods: []*v1.Pod{
|
||||
st.MakePod().Name("pod1").Label("key1", "val").SpreadConstraint(1, "node", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), nil, nil, nil, nil).Container("image").Node("fake-node1").Obj(),
|
||||
st.MakePod().Name("pod2").Label("key1", "val").SpreadConstraint(1, "zone", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), nil, nil, nil, nil).Container("image").Node("fake-node2").Obj(),
|
||||
st.MakePod().Name("pod3").Label("key1", "val").SpreadConstraint(1, "region", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), nil, nil, nil, nil).Container("image").Node("fake-node2").Obj(),
|
||||
st.MakePod().Name("pod4").Label("key1", "val").SpreadConstraint(1, "service", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), nil, nil, nil, nil).Container("image").Node("fake-node2").Obj(),
|
||||
},
|
||||
pods: []*v1.Pod{
|
||||
// - Pod3 and Pod4 will be rejected by the PodTopologySpread plugin.
|
||||
st.MakePod().Name("pod3").Label("key1", "val").SpreadConstraint(1, "node", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), ptr.To(int32(3)), nil, nil, nil).Container("image").Obj(),
|
||||
st.MakePod().Name("pod4").Label("key1", "val").SpreadConstraint(1, "zone", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), ptr.To(int32(3)), nil, nil, nil).Container("image").Obj(),
|
||||
// - Pod5, Pod6, Pod7, Pod8, Pod9 will be rejected by the PodTopologySpread plugin.
|
||||
st.MakePod().Name("pod5").Label("key1", "val").SpreadConstraint(1, "node", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), ptr.To(int32(3)), nil, nil, nil).Container("image").Obj(),
|
||||
st.MakePod().Name("pod6").Label("key1", "val").SpreadConstraint(1, "zone", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), ptr.To(int32(3)), nil, nil, nil).Container("image").Obj(),
|
||||
st.MakePod().Name("pod7").Label("key1", "val").SpreadConstraint(1, "region", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), ptr.To(int32(3)), nil, nil, nil).Container("image").Obj(),
|
||||
st.MakePod().Name("pod8").Label("key1", "val").SpreadConstraint(1, "other", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), ptr.To(int32(3)), nil, nil, nil).Container("image").Obj(),
|
||||
st.MakePod().Name("pod9").Label("key1", "val").SpreadConstraint(1, "service", v1.DoNotSchedule, st.MakeLabelSelector().Exists("key1").Obj(), ptr.To(int32(3)), nil, nil, nil).Container("image").Obj(),
|
||||
},
|
||||
triggerFn: func(testCtx *testutils.TestContext) (map[framework.ClusterEvent]uint64, error) {
|
||||
// Trigger an Node update event.
|
||||
// It should requeue pod4 only because this node only has zone label, and doesn't have node label that pod3 requires.
|
||||
node := st.MakeNode().Name("fake-node2").Label("zone", "fake-node").Obj()
|
||||
// It should requeue pod5 because it deletes the "node" label from fake-node2.
|
||||
// It should requeue pod6 because the update adds the "zone" label to fake-node2.
|
||||
// It should not requeue pod7 because the update does not change the value of "region" label.
|
||||
// It should not requeue pod8 because the update does not add the "other" label.
|
||||
// It should requeue pod9 because the update changes the value of "service" label.
|
||||
node := st.MakeNode().Name("fake-node2").Label("zone", "fake-node").Label("region", "fake-node").Label("service", "service-b").Obj()
|
||||
if _, err := testCtx.ClientSet.CoreV1().Nodes().Update(testCtx.Ctx, node, metav1.UpdateOptions{}); err != nil {
|
||||
return nil, fmt.Errorf("failed to update node: %w", err)
|
||||
}
|
||||
return map[framework.ClusterEvent]uint64{framework.NodeLabelChange: 1}, nil
|
||||
},
|
||||
wantRequeuedPods: sets.New("pod4"),
|
||||
wantRequeuedPods: sets.New("pod5", "pod6", "pod9"),
|
||||
enableSchedulingQueueHint: []bool{true},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user