feat: assemble Go scheduler and backend workers
This commit is contained in:
@@ -77,28 +77,16 @@ type Worker struct {
|
||||
// returns true, all recovery information exists in Kubernetes/OpenSandbox and
|
||||
// the assignment message can be acknowledged immediately.
|
||||
func (w Worker) Accept(ctx context.Context, assignment taskassignment.Assignment) (bool, error) {
|
||||
if w.Backend == nil || w.Tasks == nil || w.Bootstrap == nil {
|
||||
return false, errors.New("backend, Gitea task state, and runner bootstrap are required")
|
||||
if w.Backend == nil || w.Bootstrap == nil {
|
||||
return false, errors.New("backend and runner bootstrap are required")
|
||||
}
|
||||
if assignment.ID == "" || assignment.Task == nil {
|
||||
return false, errors.New("valid assignment is required")
|
||||
}
|
||||
terminal, err := w.Tasks.Terminal(ctx, assignment.Task.GetId())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
executor, err := w.Backend.Find(ctx, assignment.ID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if terminal {
|
||||
if executor != nil {
|
||||
if err := w.Backend.Delete(ctx, executor); err != nil {
|
||||
return false, err
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
if executor == nil {
|
||||
launch, launchErr := w.launchSpec(assignment)
|
||||
if launchErr != nil {
|
||||
|
||||
Reference in New Issue
Block a user