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

Commit 7ef45da

Browse files
authored
Merge pull request #643 from hex108/bug
Return err in Allocate if any error occurs
2 parents 5df06f3 + 9c87f3d commit 7ef45da

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pkg/scheduler/actions/allocate/allocate.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ func (alloc *allocateAction) Execute(ssn *framework.Session) {
147147
glog.V(3).Infof("Binding Task <%v/%v> to node <%v>",
148148
task.Namespace, task.Name, node.Name)
149149
if err := ssn.Allocate(task, node.Name); err != nil {
150-
glog.Errorf("Failed to bind Task %v on %v in Session %v",
151-
task.UID, node.Name, ssn.UID)
150+
glog.Errorf("Failed to bind Task %v on %v in Session %v, err: %v",
151+
task.UID, node.Name, ssn.UID, err)
152152
continue
153153
}
154154
assigned = true

pkg/scheduler/framework/session.go

+5
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,12 @@ func (ssn *Session) Allocate(task *api.TaskInfo, hostname string) error {
235235
if err := job.UpdateTaskStatus(task, api.Allocated); err != nil {
236236
glog.Errorf("Failed to update task <%v/%v> status to %v in Session <%v>: %v",
237237
task.Namespace, task.Name, api.Allocated, ssn.UID, err)
238+
return err
238239
}
239240
} else {
240241
glog.Errorf("Failed to found Job <%s> in Session <%s> index when binding.",
241242
task.Job, ssn.UID)
243+
return fmt.Errorf("failed to find job %s", task.Job)
242244
}
243245

244246
task.NodeName = hostname
@@ -247,12 +249,14 @@ func (ssn *Session) Allocate(task *api.TaskInfo, hostname string) error {
247249
if err := node.AddTask(task); err != nil {
248250
glog.Errorf("Failed to add task <%v/%v> to node <%v> in Session <%v>: %v",
249251
task.Namespace, task.Name, hostname, ssn.UID, err)
252+
return err
250253
}
251254
glog.V(3).Infof("After allocated Task <%v/%v> to Node <%v>: idle <%v>, used <%v>, releasing <%v>",
252255
task.Namespace, task.Name, node.Name, node.Idle, node.Used, node.Releasing)
253256
} else {
254257
glog.Errorf("Failed to found Node <%s> in Session <%s> index when binding.",
255258
hostname, ssn.UID)
259+
return fmt.Errorf("failed to find node %s", hostname)
256260
}
257261

258262
// Callbacks
@@ -269,6 +273,7 @@ func (ssn *Session) Allocate(task *api.TaskInfo, hostname string) error {
269273
if err := ssn.dispatch(task); err != nil {
270274
glog.Errorf("Failed to dispatch task <%v/%v>: %v",
271275
task.Namespace, task.Name, err)
276+
return err
272277
}
273278
}
274279
}

0 commit comments

Comments
 (0)