Skip to content

Commit

Permalink
Add reSync task callback
Browse files Browse the repository at this point in the history
Signed-off-by: Xuzheng Chang <changxuzheng@huawei.com>
  • Loading branch information
Monokaix committed Sep 11, 2023
1 parent 921c266 commit 5249bba
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/scheduler/api/job_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
batch "volcano.sh/apis/pkg/apis/batch/v1alpha1"
"volcano.sh/apis/pkg/apis/scheduling"
"volcano.sh/apis/pkg/apis/scheduling/v1beta1"

volumescheduling "volcano.sh/volcano/pkg/scheduler/capabilities/volumebinding"
)

Expand Down Expand Up @@ -130,6 +131,11 @@ type TaskInfo struct {
NumaInfo *TopologyInfo
PodVolumes *volumescheduling.PodVolumes
Pod *v1.Pod

// CustomBindErrHandler is a custom callback func called when task bind err.
CustomBindErrHandler func() error
// CustomBindErrHandlerSucceeded indicates whether CustomBindErrHandler is executed successfully.
CustomBindErrHandlerSucceeded bool
}

func getJobID(pod *v1.Pod) JobID {
Expand Down
15 changes: 15 additions & 0 deletions pkg/scheduler/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -961,9 +961,24 @@ func (sc *SchedulerCache) processResyncTask() {
return
}

reSynced := false
if err := sc.syncTask(task); err != nil {
klog.Errorf("Failed to sync pod <%v/%v>, retry it.", task.Namespace, task.Name)
sc.resyncTask(task)
reSynced = true
}

// execute custom bind err handler call back func if exists.
if task.CustomBindErrHandler != nil && !task.CustomBindErrHandlerSucceeded {
err := task.CustomBindErrHandler()
if err != nil {
klog.ErrorS(err, "Failed to execute custom bind err handler, retry it.")
} else {
task.CustomBindErrHandlerSucceeded = true
}
if !task.CustomBindErrHandlerSucceeded && !reSynced {
sc.resyncTask(task)
}
}
}

Expand Down

0 comments on commit 5249bba

Please sign in to comment.