Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Return err in functions of session.go if any error occurs #651

Merged
merged 1 commit into from
Mar 19, 2019
Merged
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
9 changes: 9 additions & 0 deletions pkg/scheduler/framework/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ func (ssn *Session) Pipeline(task *api.TaskInfo, hostname string) error {
if err := job.UpdateTaskStatus(task, api.Pipelined); err != nil {
glog.Errorf("Failed to update task <%v/%v> status to %v in Session <%v>: %v",
task.Namespace, task.Name, api.Pipelined, ssn.UID, err)
return err
}
} else {
glog.Errorf("Failed to found Job <%s> in Session <%s> index when binding.",
task.Job, ssn.UID)
return fmt.Errorf("failed to find job %s when binding", task.Job)
}

task.NodeName = hostname
Expand All @@ -205,12 +207,14 @@ func (ssn *Session) Pipeline(task *api.TaskInfo, hostname string) error {
if err := node.AddTask(task); err != nil {
glog.Errorf("Failed to add task <%v/%v> to node <%v> in Session <%v>: %v",
task.Namespace, task.Name, hostname, ssn.UID, err)
return err
}
glog.V(3).Infof("After added Task <%v/%v> to Node <%v>: idle <%v>, used <%v>, releasing <%v>",
task.Namespace, task.Name, node.Name, node.Idle, node.Used, node.Releasing)
} else {
glog.Errorf("Failed to found Node <%s> in Session <%s> index when binding.",
hostname, ssn.UID)
return fmt.Errorf("failed to find node %s", hostname)
}

for _, eh := range ssn.eventHandlers {
Expand Down Expand Up @@ -295,10 +299,12 @@ func (ssn *Session) dispatch(task *api.TaskInfo) error {
if err := job.UpdateTaskStatus(task, api.Binding); err != nil {
glog.Errorf("Failed to update task <%v/%v> status to %v in Session <%v>: %v",
task.Namespace, task.Name, api.Binding, ssn.UID, err)
return err
}
} else {
glog.Errorf("Failed to found Job <%s> in Session <%s> index when binding.",
task.Job, ssn.UID)
return fmt.Errorf("failed to find job %s", task.Job)
}

metrics.UpdateTaskScheduleDuration(metrics.Duration(task.Pod.CreationTimestamp.Time))
Expand All @@ -316,17 +322,20 @@ func (ssn *Session) Evict(reclaimee *api.TaskInfo, reason string) error {
if err := job.UpdateTaskStatus(reclaimee, api.Releasing); err != nil {
glog.Errorf("Failed to update task <%v/%v> status to %v in Session <%v>: %v",
reclaimee.Namespace, reclaimee.Name, api.Releasing, ssn.UID, err)
return err
}
} else {
glog.Errorf("Failed to found Job <%s> in Session <%s> index when binding.",
reclaimee.Job, ssn.UID)
return fmt.Errorf("failed to find job %s", reclaimee.Job)
}

// Update task in node.
if node, found := ssn.Nodes[reclaimee.NodeName]; found {
if err := node.UpdateTask(reclaimee); err != nil {
glog.Errorf("Failed to update task <%v/%v> in Session <%v>: %v",
reclaimee.Namespace, reclaimee.Name, ssn.UID, err)
return err
}
}

Expand Down