From b9d24b98b93b64e359ae7984917a6094c6de991c Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Sat, 6 Nov 2021 09:58:53 +0300 Subject: update worker's vector Signed-off-by: Valery Piashchynski --- worker_watcher/container/channel/vec.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/worker_watcher/container/channel/vec.go b/worker_watcher/container/channel/vec.go index fd50c8d1..63df052f 100644 --- a/worker_watcher/container/channel/vec.go +++ b/worker_watcher/container/channel/vec.go @@ -69,8 +69,16 @@ func (v *Vec) Push(w worker.BaseProcess) { // replace with the new one and return from the loop // new worker can be ttl-ed at this moment, it's possible to replace TTL-ed worker with new TTL-ed worker // But this case will be handled in the worker_watcher::Get - v.workers <- w - return + select { + case v.workers <- w: + return + // the place for the new worker was occupied before + default: + // kill the new worker and reallocate it + w.State().Set(worker.StateInvalid) + _ = w.Kill() + return + } } } } -- cgit v1.2.3 From c639dd2ffde1b6c8679d4b3fe6f16130ed091299 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Sat, 6 Nov 2021 17:31:09 +0300 Subject: remove redundand error check Signed-off-by: Valery Piashchynski --- worker_watcher/worker_watcher.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/worker_watcher/worker_watcher.go b/worker_watcher/worker_watcher.go index 544c9789..6cd01177 100755 --- a/worker_watcher/worker_watcher.go +++ b/worker_watcher/worker_watcher.go @@ -112,10 +112,6 @@ func (ww *workerWatcher) Take(ctx context.Context) (worker.BaseProcess, error) { return nil, errors.E(op, err) } - if err != nil { - return nil, errors.E(op, err) - } - switch w.State().Value() { // return only workers in the Ready state // check first -- cgit v1.2.3