From 471ee08c034787b5ea1b5f3380b7a81632b761ad Mon Sep 17 00:00:00 2001 From: Viren6 <94880762+Viren6@users.noreply.github.com> Date: Sat, 17 Aug 2024 07:17:34 +0100 Subject: [PATCH] Fix worker updates --- server/fishtest/api.py | 2 +- worker/sri.txt | 2 +- worker/worker.py | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/server/fishtest/api.py b/server/fishtest/api.py index 22755e5fa..6a403e512 100644 --- a/server/fishtest/api.py +++ b/server/fishtest/api.py @@ -34,7 +34,7 @@ according to the route/URL mapping defined in `__init__.py`. """ -WORKER_VERSION = 241 +WORKER_VERSION = 242 @exception_view_config(HTTPException) diff --git a/worker/sri.txt b/worker/sri.txt index ee2cad5b6..24eef0e03 100644 --- a/worker/sri.txt +++ b/worker/sri.txt @@ -1 +1 @@ -{"__version": 241, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "BMuQUpxZAKF0aP6ByTZY1r06MfPoIbdG2xraTrDQQRKgvhzJo6CKmeX2P8vX/QDm", "games.py": "9dFaa914vpqT7q4LLx2LlDdYwK6QFVX3h7+XRt18ATX0lt737rvFeBIiqakkttNC"} +{"__version": 242, "updater.py": "Mg+pWOgGA0gSo2TuXuuLCWLzwGwH91rsW1W3ixg3jYauHQpRMtNdGnCfuD1GqOhV", "worker.py": "26jTXaNVh+1WI3Y7UrVGvmG55/IoiEoy4DzSYHTQApPFmpttGqH0FZXRk3AKI59S", "games.py": "9dFaa914vpqT7q4LLx2LlDdYwK6QFVX3h7+XRt18ATX0lt737rvFeBIiqakkttNC"} diff --git a/worker/worker.py b/worker/worker.py index bfc40c95d..16483da22 100644 --- a/worker/worker.py +++ b/worker/worker.py @@ -68,7 +68,7 @@ MIN_CLANG_MAJOR = 8 MIN_CLANG_MINOR = 0 -WORKER_VERSION = 241 +WORKER_VERSION = 242 FILE_LIST = ["updater.py", "worker.py", "games.py"] HTTP_TIMEOUT = 30.0 INITIAL_RETRY_TIME = 15.0 @@ -1238,7 +1238,7 @@ def utcoffset(): return "{}{:02d}:{:02d}".format("+" if utcoffset >= 0 else "-", hh, mm) -def verify_worker_version(remote, username, password): +def verify_worker_version(remote, username, password, worker_lock): # Returns: # True: we are the right version and have the correct credentials # False: incorrect credentials (the user may have been blocked in the meantime) @@ -1257,6 +1257,7 @@ def verify_worker_version(remote, username, password): print("Updating worker version to {}".format(req["version"])) backup_log() try: + worker_lock.release() update() except Exception as e: print( @@ -1277,6 +1278,7 @@ def fetch_and_handle_task( current_state, clear_binaries, global_cache, + worker_lock, ): # This function should normally not raise exceptions. # Unusual conditions are handled by returning False. @@ -1291,7 +1293,7 @@ def fetch_and_handle_task( ) # Check the worker version and upgrade if necessary - ret = verify_worker_version(remote, worker_info["username"], password) + ret = verify_worker_version(remote, worker_info["username"], password, worker_lock) if ret is False: current_state["alive"] = False if not ret: @@ -1506,7 +1508,12 @@ def worker(): # Check the worker version and upgrade if necessary try: - if verify_worker_version(remote, options.username, options.password) is False: + if ( + verify_worker_version( + remote, options.username, options.password, worker_lock + ) + is False + ): return 1 except Exception as e: print("Exception verifying worker version:\n", e, sep="", file=sys.stderr) @@ -1592,6 +1599,7 @@ def worker(): current_state, clear_binaries, options.global_cache, + worker_lock, ) if not current_state["alive"]: # the user may have pressed Ctrl-C... break