Skip to content

Commit

Permalink
Don't depend on ready condition of nodes instead of taints in session
Browse files Browse the repository at this point in the history
Signed-off-by: Monokaix <[email protected]>
  • Loading branch information
Monokaix committed Sep 30, 2024
1 parent 9712489 commit e697aca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 22 deletions.
17 changes: 2 additions & 15 deletions pkg/scheduler/api/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,25 +298,12 @@ func (ni *NodeInfo) setNodeState(node *v1.Node) {
klog.ErrorS(nil, "Node out of sync", "name", ni.Name, "resources", resources)
}

// If node not ready, e.g. power off
for _, cond := range node.Status.Conditions {
if cond.Type == v1.NodeReady && cond.Status != v1.ConditionTrue {
ni.State = NodeState{
Phase: NotReady,
Reason: "NotReady",
}
klog.Warningf("set the node %s status to %s.", node.Name, NotReady.String())
return
}
}

// Node is ready (ignore node conditions because of taint/toleration)
// Node is ready (ignore node conditions because of taint/toleration), for more detail please see
// https://github.com/kubernetes/design-proposals-archive/blob/main/scheduling/taint-node-by-condition.md.
ni.State = NodeState{
Phase: Ready,
Reason: "",
}

klog.V(4).Infof("set the node %s status to %s.", node.Name, Ready.String())
}

// SetNode sets kubernetes node object to nodeInfo object
Expand Down
19 changes: 12 additions & 7 deletions pkg/scheduler/cache/event_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"volcano.sh/apis/pkg/apis/scheduling"
schedulingv1 "volcano.sh/apis/pkg/apis/scheduling/v1beta1"
"volcano.sh/volcano/pkg/scheduler/api"
schedulingapi "volcano.sh/volcano/pkg/scheduler/api"
"volcano.sh/volcano/pkg/scheduler/util"
)

Expand Down Expand Up @@ -644,19 +645,23 @@ func TestSchedulerCache_DeleteQueueV1beta1(t *testing.T) {
}

func TestSchedulerCache_SyncNode(t *testing.T) {
n1 := util.BuildNode("n1", nil, map[string]string{"label-key": "label-value"})
expectedNodeInfo := schedulingapi.NewNodeInfo(n1)
expectedNodeInfo.State.Phase = schedulingapi.Ready

tests := []struct {
name string
cache SchedulerCache
nodes []*v1.Node
nodeName string
nodeSelector map[string]sets.Empty
expectedNodes map[string]struct{}
expectedNodes map[string]*schedulingapi.NodeInfo
wantErr bool
}{
{
name: "Node not exists",
nodeName: "n1",
expectedNodes: map[string]struct{}{},
expectedNodes: map[string]*schedulingapi.NodeInfo{},
wantErr: true,
},
{
Expand All @@ -668,7 +673,7 @@ func TestSchedulerCache_SyncNode(t *testing.T) {
nodeSelector: map[string]sets.Empty{
"label-key:label-value": {},
},
expectedNodes: map[string]struct{}{"n1": {}},
expectedNodes: map[string]*schedulingapi.NodeInfo{"n1": expectedNodeInfo},
wantErr: false,
},
{
Expand All @@ -680,7 +685,7 @@ func TestSchedulerCache_SyncNode(t *testing.T) {
nodeSelector: map[string]sets.Empty{
"label-key:label-value": {},
},
expectedNodes: map[string]struct{}{},
expectedNodes: map[string]*schedulingapi.NodeInfo{},
wantErr: false,
},
}
Expand All @@ -697,9 +702,9 @@ func TestSchedulerCache_SyncNode(t *testing.T) {
t.Errorf("SyncNode() error = %v, wantErr %v", err, tt.wantErr)
}

actualNodes := make(map[string]struct{})
for n := range sc.Nodes {
actualNodes[n] = struct{}{}
actualNodes := make(map[string]*schedulingapi.NodeInfo)
for n, i := range sc.Nodes {
actualNodes[n] = i
}
assert.Equal(t, tt.expectedNodes, actualNodes)
})
Expand Down

0 comments on commit e697aca

Please sign in to comment.