From c49a9ef35fdee98444f191ced47b62d357566d78 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Thu, 6 Jun 2024 11:20:02 +0200 Subject: [PATCH 1/2] Fix seek in slurm memory check Fixes https://sentry.galaxyproject.org/share/issue/e196a12836fe40da83c5e9e24c4c8329/: ``` UnsupportedOperation: can't do nonzero end-relative seeks File "galaxy/jobs/runners/slurm.py", line 217, in __check_memory_limit f.seek(-2048, os.SEEK_END) ``` which has probably been broken since we moved to python 3. --- lib/galaxy/jobs/runners/slurm.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/galaxy/jobs/runners/slurm.py b/lib/galaxy/jobs/runners/slurm.py index 98c373d96645..b8764ddea7de 100644 --- a/lib/galaxy/jobs/runners/slurm.py +++ b/lib/galaxy/jobs/runners/slurm.py @@ -7,7 +7,10 @@ from galaxy import model from galaxy.jobs.runners.drmaa import DRMAAJobRunner -from galaxy.util import commands +from galaxy.util import ( + commands, + unicodify, +) from galaxy.util.custom_logging import get_logger log = get_logger(__name__) @@ -212,12 +215,12 @@ def __check_memory_limit(self, efile_path): """ try: log.debug("Checking %s for exceeded memory message from SLURM", efile_path) - with open(efile_path) as f: + with open(efile_path, "rb") as f: if os.path.getsize(efile_path) > 2048: f.seek(-2048, os.SEEK_END) f.readline() for line in f.readlines(): - stripped_line = line.strip() + stripped_line = unicodify(line) if stripped_line == SLURM_MEMORY_LIMIT_EXCEEDED_MSG: return OUT_OF_MEMORY_MSG elif any(_ in stripped_line for _ in SLURM_MEMORY_LIMIT_EXCEEDED_PARTIAL_WARNINGS): From cf322eb531ca6ae4a3852138123a08019563f93e Mon Sep 17 00:00:00 2001 From: Marius van den Beek Date: Thu, 6 Jun 2024 12:47:34 +0200 Subject: [PATCH 2/2] restore line.strip() Co-authored-by: Nicola Soranzo --- lib/galaxy/jobs/runners/slurm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/jobs/runners/slurm.py b/lib/galaxy/jobs/runners/slurm.py index b8764ddea7de..db1ed9b3d002 100644 --- a/lib/galaxy/jobs/runners/slurm.py +++ b/lib/galaxy/jobs/runners/slurm.py @@ -220,7 +220,7 @@ def __check_memory_limit(self, efile_path): f.seek(-2048, os.SEEK_END) f.readline() for line in f.readlines(): - stripped_line = unicodify(line) + stripped_line = unicodify(line.strip()) if stripped_line == SLURM_MEMORY_LIMIT_EXCEEDED_MSG: return OUT_OF_MEMORY_MSG elif any(_ in stripped_line for _ in SLURM_MEMORY_LIMIT_EXCEEDED_PARTIAL_WARNINGS):