Manager: prevent error when fetching task that was never assigned
Prevent an error when fetching a task that was never assigned to a worker. The error: ``` WRN error fetching task worker error="fetching worker : worker not found: sql: no rows in result set" ```
This commit is contained in:
parent
234cfbf983
commit
8b322e84f8
@ -138,15 +138,17 @@ func (f *Flamenco) FetchTask(e echo.Context, taskID string) error {
|
|||||||
}
|
}
|
||||||
apiTask := taskJobWorkertoAPI(taskJobWorker)
|
apiTask := taskJobWorkertoAPI(taskJobWorker)
|
||||||
|
|
||||||
// Fetch the worker. TODO: get rid of this conversion, just include the
|
if taskJobWorker.WorkerUUID != "" {
|
||||||
// worker's UUID and let the caller fetch the worker info themselves if
|
// Fetch the worker. TODO: get rid of this conversion, just include the
|
||||||
// necessary.
|
// worker's UUID and let the caller fetch the worker info themselves if
|
||||||
taskWorker, err := f.persist.FetchWorker(ctx, taskJobWorker.WorkerUUID)
|
// necessary.
|
||||||
if err != nil {
|
taskWorker, err := f.persist.FetchWorker(ctx, taskJobWorker.WorkerUUID)
|
||||||
logger.Warn().Err(err).Msg("error fetching task worker")
|
if err != nil {
|
||||||
return sendAPIError(e, http.StatusInternalServerError, "error fetching task worker")
|
logger.Warn().Err(err).Msg("error fetching task worker")
|
||||||
|
return sendAPIError(e, http.StatusInternalServerError, "error fetching task worker")
|
||||||
|
}
|
||||||
|
apiTask.Worker = workerToTaskWorker(taskWorker)
|
||||||
}
|
}
|
||||||
apiTask.Worker = workerToTaskWorker(taskWorker)
|
|
||||||
|
|
||||||
// Fetch & convert the failure list.
|
// Fetch & convert the failure list.
|
||||||
failedWorkers, err := f.persist.FetchTaskFailureList(ctx, &taskJobWorker.Task)
|
failedWorkers, err := f.persist.FetchTaskFailureList(ctx, &taskJobWorker.Task)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user