fix task error check
This commit is contained in:
parent
290acc158a
commit
628847388d
1 changed files with 21 additions and 19 deletions
|
@ -202,6 +202,7 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
|||
var ts types.TaskStatus
|
||||
_, err := rpcServer.Call(ctx, w.Conn, "task-status", tsr, &ts)
|
||||
|
||||
if err != nil {
|
||||
// Find better way to compare errors which where send via websocket
|
||||
if strings.HasSuffix(err.Error(), constants.ErrTaskDoesNotExist.Error()) {
|
||||
// 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
|
||||
|
@ -214,7 +215,7 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
|||
slog.Info("Updating task done", "id", taskID, "status", constants.TASK_STATUS_FAILED)
|
||||
|
||||
return
|
||||
} else if err != nil {
|
||||
} 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)
|
||||
|
@ -224,6 +225,7 @@ func updateWorkerTaskStatus(ctx context.Context) {
|
|||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", taskID, ts.Task.Status, ts.Task.Log)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Reference in a new issue