From b26374d480bd9d333e7225d38b1c0c9cd5cacf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Thu, 28 Jul 2022 14:27:44 +0200 Subject: [PATCH] Manager: when worker goes to sleep, log in task log which worker When a worker's tasks get requeued because it goes to sleep, the task log will now mention the worker identification (name + UUID). This aids in figuring out what happened to tasks. --- internal/manager/api_impl/workers.go | 2 +- internal/manager/api_impl/workers_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/manager/api_impl/workers.go b/internal/manager/api_impl/workers.go index 56c145c6..f2019c8a 100644 --- a/internal/manager/api_impl/workers.go +++ b/internal/manager/api_impl/workers.go @@ -253,7 +253,7 @@ func (f *Flamenco) WorkerStateChanged(e echo.Context) error { // Re-queue all tasks (should be only one) this worker is now working on. if prevStatus == api.WorkerStatusAwake && w.Status != api.WorkerStatusAwake { err := f.stateMachine.RequeueActiveTasksOfWorker(bgCtx, w, - fmt.Sprintf("worker changed status to '%s'", w.Status)) + fmt.Sprintf("worker %s changed status to '%s'", w.Identifier(), w.Status)) if err != nil { logger.Warn().Err(err).Msg("error re-queueing worker tasks after it changed to non-awake status") } diff --git a/internal/manager/api_impl/workers_test.go b/internal/manager/api_impl/workers_test.go index 70903af4..dec0a48b 100644 --- a/internal/manager/api_impl/workers_test.go +++ b/internal/manager/api_impl/workers_test.go @@ -349,7 +349,8 @@ func TestWorkerStateChanged(t *testing.T) { savedWorker.Status = api.WorkerStatusAsleep mf.persistence.EXPECT().SaveWorkerStatus(gomock.Any(), &savedWorker).Return(nil) mf.persistence.EXPECT().WorkerSeen(gomock.Any(), &worker) - mf.stateMachine.EXPECT().RequeueActiveTasksOfWorker(gomock.Any(), &worker, "worker changed status to 'asleep'") + mf.stateMachine.EXPECT().RequeueActiveTasksOfWorker(gomock.Any(), &worker, + "worker дрон (e7632d62-c3b8-4af0-9e78-01752928952c) changed status to 'asleep'") // Perform the request echo := mf.prepareMockedJSONRequest(api.WorkerStateChanged{