From c8c7ac21058ba23e951cb5032988a52e887de6e0 Mon Sep 17 00:00:00 2001 From: Jun Gong Date: Tue, 19 Mar 2019 11:48:05 +0800 Subject: [PATCH] Return err in functions of session.go if any error occurs --- pkg/scheduler/framework/session.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/scheduler/framework/session.go b/pkg/scheduler/framework/session.go index 5ee293d9f..399f7c417 100644 --- a/pkg/scheduler/framework/session.go +++ b/pkg/scheduler/framework/session.go @@ -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 @@ -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 { @@ -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)) @@ -316,10 +322,12 @@ 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. @@ -327,6 +335,7 @@ func (ssn *Session) Evict(reclaimee *api.TaskInfo, reason string) error { 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 } }