Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the scheduler panic whenever the GPU is lost on node #306

Merged
merged 5 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions pkg/scheduler/api/node_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,18 @@ func (ni *NodeInfo) SetNode(node *v1.Node) {
}
}

func (ni *NodeInfo) allocateIdleResource(ti *TaskInfo) error {
if ti.Resreq.LessEqual(ni.Idle) {
ni.Idle.Sub(ti.Resreq)
return nil
}
ni.State = NodeState{
Phase: NotReady,
Reason: "OutOfSync",
}
return fmt.Errorf("Selected node NotReady")
}

// AddTask is used to add a task in nodeInfo object
func (ni *NodeInfo) AddTask(task *TaskInfo) error {
key := PodKey(task.Pod)
Expand All @@ -176,12 +188,16 @@ func (ni *NodeInfo) AddTask(task *TaskInfo) error {
if ni.Node != nil {
switch ti.Status {
case Releasing:
if err := ni.allocateIdleResource(ti); err != nil {
return err
}
ni.Releasing.Add(ti.Resreq)
ni.Idle.Sub(ti.Resreq)
case Pipelined:
ni.Releasing.Sub(ti.Resreq)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this face the same problem?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, So I deleted this line and replace it to line 191-193.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@william-wang Could you add more comments why this can cause a panic?
In customer's environment, when the GPU was lost. the ni.Idle decreased and the value was less than ti.Resreq. Then the panic happened in Sub func. So we need to add a judgement before the execution of ni.Idle.Sub(ti.Resreq).

default:
ni.Idle.Sub(ti.Resreq)
if err := ni.allocateIdleResource(ti); err != nil {
return err
}
}

ni.Used.Add(ti.Resreq)
Expand Down
19 changes: 19 additions & 0 deletions pkg/scheduler/api/node_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ func TestNodeInfo_AddPod(t *testing.T) {
case01Node := buildNode("n1", buildResourceList("8000m", "10G"))
case01Pod1 := buildPod("c1", "p1", "n1", v1.PodRunning, buildResourceList("1000m", "1G"), []metav1.OwnerReference{}, make(map[string]string))
case01Pod2 := buildPod("c1", "p2", "n1", v1.PodRunning, buildResourceList("2000m", "2G"), []metav1.OwnerReference{}, make(map[string]string))
// case2
case02Node := buildNode("n2", buildResourceList("2000m", "1G"))
case02Pod1 := buildPod("c2", "p1", "n2", v1.PodUnknown, buildResourceList("1000m", "2G"), []metav1.OwnerReference{}, make(map[string]string))

tests := []struct {
name string
Expand All @@ -63,6 +66,22 @@ func TestNodeInfo_AddPod(t *testing.T) {
},
},
},
{
name: "add 1 unknown pod",
node: case02Node,
pods: []*v1.Pod{case02Pod1},
expected: &NodeInfo{
Name: "n2",
Node: case02Node,
Idle: buildResource("2000m", "1G"),
Used: EmptyResource(),
Releasing: EmptyResource(),
Allocatable: buildResource("2000m", "1G"),
Capability: buildResource("2000m", "1G"),
State: NodeState{Phase: NotReady, Reason: "OutOfSync"},
Tasks: map[TaskID]*TaskInfo{},
},
},
}

for i, test := range tests {
Expand Down