Manager: prevent logging an error when fetching unknown worker

Prevent logging an error in the persistence layer when an unknown worker
is requested.

This reduces the noise & confusion when the web interface is showing the
details of a worker, but the worker gets removed by someone else. Or when
the Manager doesn't know about a Worker and it's trying to connect.

See #104282.
This commit is contained in:
Sybren A. Stüvel 2024-01-25 12:36:32 +01:00
parent 70faa4e225
commit 9afd79d8c0

View File

@ -75,10 +75,14 @@ func (db *DB) FetchWorker(ctx context.Context, uuid string) (*Worker, error) {
w := Worker{}
tx := db.gormDB.WithContext(ctx).
Preload("Tags").
First(&w, "uuid = ?", uuid)
Find(&w, "uuid = ?", uuid).
Limit(1)
if tx.Error != nil {
return nil, workerError(tx.Error, "fetching worker")
}
if w.ID == 0 {
return nil, ErrWorkerNotFound
}
return &w, nil
}