mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-12-07 18:06:21 +00:00
feature(scheduler): simplify QueueingHint by introducing new statuses
This commit is contained in:
@@ -94,7 +94,7 @@ func (pl *NodeAffinity) EventsToRegister() []framework.ClusterEventWithHint {
|
||||
func (pl *NodeAffinity) isSchedulableAfterNodeChange(logger klog.Logger, pod *v1.Pod, oldObj, newObj interface{}) (framework.QueueingHint, error) {
|
||||
originalNode, modifiedNode, err := util.As[*v1.Node](oldObj, newObj)
|
||||
if err != nil {
|
||||
return framework.QueueAfterBackoff, err
|
||||
return framework.Queue, err
|
||||
}
|
||||
|
||||
if pl.addedNodeSelector != nil && !pl.addedNodeSelector.Match(modifiedNode) {
|
||||
@@ -105,7 +105,7 @@ func (pl *NodeAffinity) isSchedulableAfterNodeChange(logger klog.Logger, pod *v1
|
||||
requiredNodeAffinity := nodeaffinity.GetRequiredNodeAffinity(pod)
|
||||
isMatched, err := requiredNodeAffinity.Match(modifiedNode)
|
||||
if err != nil {
|
||||
return framework.QueueAfterBackoff, err
|
||||
return framework.Queue, err
|
||||
}
|
||||
if !isMatched {
|
||||
logger.V(4).Info("node was created or updated, but doesn't matches with the pod's NodeAffinity", "pod", klog.KObj(pod), "node", klog.KObj(modifiedNode))
|
||||
@@ -116,14 +116,14 @@ func (pl *NodeAffinity) isSchedulableAfterNodeChange(logger klog.Logger, pod *v1
|
||||
if originalNode != nil {
|
||||
wasMatched, err = requiredNodeAffinity.Match(originalNode)
|
||||
if err != nil {
|
||||
return framework.QueueAfterBackoff, err
|
||||
return framework.Queue, err
|
||||
}
|
||||
}
|
||||
|
||||
if !wasMatched {
|
||||
// This modification makes this Node match with Pod's NodeAffinity.
|
||||
logger.V(4).Info("node was created or updated, and matches with the pod's NodeAffinity", "pod", klog.KObj(pod), "node", klog.KObj(modifiedNode))
|
||||
return framework.QueueAfterBackoff, nil
|
||||
return framework.Queue, nil
|
||||
}
|
||||
|
||||
logger.V(4).Info("node was created or updated, but it doesn't make this pod schedulable", "pod", klog.KObj(pod), "node", klog.KObj(modifiedNode))
|
||||
|
||||
@@ -1189,7 +1189,7 @@ func Test_isSchedulableAfterNodeChange(t *testing.T) {
|
||||
args: &config.NodeAffinityArgs{},
|
||||
pod: podWithNodeAffinity.Obj(),
|
||||
newObj: "not-a-node",
|
||||
expectedHint: framework.QueueAfterBackoff,
|
||||
expectedHint: framework.Queue,
|
||||
expectedErr: true,
|
||||
},
|
||||
"backoff-wrong-old-object": {
|
||||
@@ -1197,7 +1197,7 @@ func Test_isSchedulableAfterNodeChange(t *testing.T) {
|
||||
pod: podWithNodeAffinity.Obj(),
|
||||
oldObj: "not-a-node",
|
||||
newObj: st.MakeNode().Obj(),
|
||||
expectedHint: framework.QueueAfterBackoff,
|
||||
expectedHint: framework.Queue,
|
||||
expectedErr: true,
|
||||
},
|
||||
"skip-queue-on-add": {
|
||||
@@ -1210,7 +1210,7 @@ func Test_isSchedulableAfterNodeChange(t *testing.T) {
|
||||
args: &config.NodeAffinityArgs{},
|
||||
pod: podWithNodeAffinity.Obj(),
|
||||
newObj: st.MakeNode().Label("foo", "bar").Obj(),
|
||||
expectedHint: framework.QueueAfterBackoff,
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
"skip-unrelated-changes": {
|
||||
args: &config.NodeAffinityArgs{},
|
||||
@@ -1245,7 +1245,7 @@ func Test_isSchedulableAfterNodeChange(t *testing.T) {
|
||||
pod: podWithNodeAffinity.Obj(),
|
||||
oldObj: st.MakeNode().Obj(),
|
||||
newObj: st.MakeNode().Label("foo", "bar").Obj(),
|
||||
expectedHint: framework.QueueAfterBackoff,
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
"skip-queue-on-add-scheduler-enforced-node-affinity": {
|
||||
args: &config.NodeAffinityArgs{
|
||||
@@ -1289,7 +1289,7 @@ func Test_isSchedulableAfterNodeChange(t *testing.T) {
|
||||
},
|
||||
pod: podWithNodeAffinity.Obj(),
|
||||
newObj: st.MakeNode().Label("foo", "bar").Obj(),
|
||||
expectedHint: framework.QueueAfterBackoff,
|
||||
expectedHint: framework.Queue,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user