fix task error check
This commit is contained in:
parent
290acc158a
commit
628847388d
1 changed files with 21 additions and 19 deletions
|
@ -202,27 +202,29 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
||||||
var ts types.TaskStatus
|
var ts types.TaskStatus
|
||||||
_, err := rpcServer.Call(ctx, w.Conn, "task-status", tsr, &ts)
|
_, err := rpcServer.Call(ctx, w.Conn, "task-status", tsr, &ts)
|
||||||
|
|
||||||
// Find better way to compare errors which where send via websocket
|
if err != nil {
|
||||||
if strings.HasSuffix(err.Error(), constants.ErrTaskDoesNotExist.Error()) {
|
// Find better way to compare errors which where send via websocket
|
||||||
// Worker says it does not know of this task, mark it failed so that we don't asks the worker about it again and again
|
if strings.HasSuffix(err.Error(), constants.ErrTaskDoesNotExist.Error()) {
|
||||||
slog.ErrorContext(ctx, "Task is unknown by worker, Failing...", "err", err, "id", taskID)
|
// Worker says it does not know of this task, mark it failed so that we don't asks the worker about it again and again
|
||||||
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", taskID, constants.TASK_STATUS_FAILED, []string{"Task Failed because it is unknown to Assigned Worker"})
|
slog.ErrorContext(ctx, "Task is unknown by worker, Failing...", "err", err, "id", taskID)
|
||||||
if err != nil {
|
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", taskID, constants.TASK_STATUS_FAILED, []string{"Task Failed because it is unknown to Assigned Worker"})
|
||||||
slog.ErrorContext(ctx, "Updating Failed Task Status", "err", err)
|
if err != nil {
|
||||||
|
slog.ErrorContext(ctx, "Updating Failed Task Status", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
slog.Info("Updating task done", "id", taskID, "status", constants.TASK_STATUS_FAILED)
|
||||||
|
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
slog.ErrorContext(ctx, "Getting Task Status", "err", err)
|
||||||
|
|
||||||
|
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2 WHERE id = $1", taskID, constants.TASK_STATUS_UNKNOWN)
|
||||||
|
if err != nil {
|
||||||
|
slog.ErrorContext(ctx, "Updating Unknown Task Status", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
slog.Info("Updating task done", "id", taskID, "status", constants.TASK_STATUS_FAILED)
|
|
||||||
|
|
||||||
return
|
|
||||||
} else if err != nil {
|
|
||||||
slog.ErrorContext(ctx, "Getting Task Status", "err", err)
|
|
||||||
|
|
||||||
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2 WHERE id = $1", taskID, constants.TASK_STATUS_UNKNOWN)
|
|
||||||
if err != nil {
|
|
||||||
slog.ErrorContext(ctx, "Updating Unknown Task Status", "err", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", taskID, ts.Task.Status, ts.Task.Log)
|
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", taskID, ts.Task.Status, ts.Task.Log)
|
||||||
|
|
Loading…
Add table
Reference in a new issue