Avoid error when fetching task that was assigned to soft-deleted worker
When a Worker is soft-deleted, references to it are not cleaned up by the database (that only happens when it is really deleted). As a result, the "last-assigned worker of a task" field is still set, but the worker itself cannot be fetched any more. This is just a quick fix to avoid an error. It's probably better to remove the soft-deletion of Workers, as the feature is not really used anyway. Or to implement it properly, so that the info is used.
This commit is contained in:
parent
55491675e2
commit
3541575a75
@ -143,11 +143,16 @@ func (f *Flamenco) FetchTask(e echo.Context, taskID string) error {
|
|||||||
// worker's UUID and let the caller fetch the worker info themselves if
|
// worker's UUID and let the caller fetch the worker info themselves if
|
||||||
// necessary.
|
// necessary.
|
||||||
taskWorker, err := f.persist.FetchWorker(ctx, taskJobWorker.WorkerUUID)
|
taskWorker, err := f.persist.FetchWorker(ctx, taskJobWorker.WorkerUUID)
|
||||||
if err != nil {
|
switch {
|
||||||
logger.Warn().Err(err).Msg("error fetching task worker")
|
case errors.Is(err, persistence.ErrWorkerNotFound):
|
||||||
|
// This is fine, workers can be soft-deleted from the database, and then
|
||||||
|
// the above FetchWorker call will not return it.
|
||||||
|
case err != nil:
|
||||||
|
logger.Warn().Err(err).Str("worker", taskJobWorker.WorkerUUID).Msg("error fetching task worker")
|
||||||
return sendAPIError(e, http.StatusInternalServerError, "error fetching task worker")
|
return sendAPIError(e, http.StatusInternalServerError, "error fetching task worker")
|
||||||
|
default:
|
||||||
|
apiTask.Worker = workerToTaskWorker(taskWorker)
|
||||||
}
|
}
|
||||||
apiTask.Worker = workerToTaskWorker(taskWorker)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch & convert the failure list.
|
// Fetch & convert the failure list.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user