fix task error check

This commit is contained in:
speatzle 2024-05-21 16:57:55 +02:00
parent 290acc158a
commit 628847388d

View file

@ -202,6 +202,7 @@ 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)
if err != nil {
// Find better way to compare errors which where send via websocket // Find better way to compare errors which where send via websocket
if strings.HasSuffix(err.Error(), constants.ErrTaskDoesNotExist.Error()) { 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 // 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) slog.Info("Updating task done", "id", taskID, "status", constants.TASK_STATUS_FAILED)
return return
} else if err != nil { } else {
slog.ErrorContext(ctx, "Getting Task Status", "err", err) 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) _, 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 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)
if err != nil { if err != nil {