diff --git a/server/fishtest/rundb.py b/server/fishtest/rundb.py index 838bf7fdb..3fc66945c 100644 --- a/server/fishtest/rundb.py +++ b/server/fishtest/rundb.py @@ -1033,7 +1033,7 @@ def sync_request_task(self, worker_info): if w["blocked"]: # updates last_updated self.workerdb.update_worker( - my_name, blocked=w["blocked"], message=w["message"] + my_name, blocked=w["blocked"], message=w["message"], username=None ) error = self.blocked_worker_message(my_name, w["message"], host_url) return {"task_waiting": False, "error": error} diff --git a/server/fishtest/templates/workers.mak b/server/fishtest/templates/workers.mak index 2e56cc0ae..e16e36922 100644 --- a/server/fishtest/templates/workers.mak +++ b/server/fishtest/templates/workers.mak @@ -66,12 +66,24 @@
Last changed: ${delta_date(diff_date(last_updated)) if last_updated is not None else "Never"}
- + % if message: + + + % endif + + + required + >
@@ -148,3 +160,15 @@ % endif + + + diff --git a/server/fishtest/views.py b/server/fishtest/views.py index e560520c2..a7797aaa2 100644 --- a/server/fishtest/views.py +++ b/server/fishtest/views.py @@ -247,9 +247,12 @@ def workers(request): ) message = message[:max_chars] message = normalize_lf(message) + if message.strip() == "": + request.session.flash("A new message is required for unblocking/blocking workers", "error") + return home(request) was_blocked = request.workerdb.get_worker(worker_name)["blocked"] request.rundb.workerdb.update_worker( - worker_name, blocked=blocked, message=message + worker_name, blocked=blocked, message=message, username=blocker_name, ) if blocked != was_blocked: request.session.flash( diff --git a/server/fishtest/workerdb.py b/server/fishtest/workerdb.py index 2783871ee..5839aec2e 100644 --- a/server/fishtest/workerdb.py +++ b/server/fishtest/workerdb.py @@ -27,13 +27,23 @@ def get_worker( else: return r - def update_worker(self, worker_name, blocked=None, message=None): + def update_worker(self, worker_name, blocked=None, message=None, username=None): + current_worker = self.get_worker(worker_name) + + new_message = message + if message and current_worker and current_worker.get("message") != message: + timestamp = datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S %Z") + new_message = ( + f"{current_worker['message']}\n{username} {timestamp}\n{message}\n" + ) + r = { "worker_name": worker_name, "blocked": blocked, - "message": message, + "message": new_message, "last_updated": datetime.now(timezone.utc), } + validate(worker_schema, r, "worker") # may throw exception self.workers.replace_one({"worker_name": worker_name}, r, upsert=True)