Add Logging

This commit is contained in:
speatzle 2024-05-21 16:52:31 +02:00
parent 93cd12c6b6
commit 3dfb113aaf

View file

@ -204,13 +204,14 @@ func updateWorkerTaskStatus(ctx context.Context) {
// 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
slog.ErrorContext(ctx, "Task is unknown by worker, Failing...", "err", err) slog.ErrorContext(ctx, "Task is unknown by worker, Failing...", "err", err, "id", ts.Task.ID)
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", ts.Task.ID, constants.TASK_STATUS_FAILED, []string{"Task Failed because it is unknown to Assigned Worker"})
_, err = db.Exec(ctx, "UPDATE tasks SET status = $2, log = log || $3 WHERE id = $1", ts.Task.ID, constants.TASK_STATUS_FAILED, []string{"Task Failed because it is unkown to Assigned Worker"})
if err != nil { if err != nil {
slog.ErrorContext(ctx, "Updating Failed Task Status", "err", err) slog.ErrorContext(ctx, "Updating Failed Task Status", "err", err)
return return
} }
slog.Info("Updating task done", "id", ts.Task.ID, "status", constants.TASK_STATUS_FAILED)
return return
} else if err != nil { } else if err != nil {
slog.ErrorContext(ctx, "Getting Task Status", "err", err) slog.ErrorContext(ctx, "Getting Task Status", "err", err)