From b4252724e5e5dc0088828778d36ae767f3608f23 Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Thu, 24 Nov 2016 13:19:48 +0000 Subject: [PATCH 1/7] Estimate the walltime usage over the last 30 days. Log at debug level if usage is over 20 seconds. --- lib/galaxy/jobs/handler.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/galaxy/jobs/handler.py b/lib/galaxy/jobs/handler.py index b408dfd3d3b..5f3677e495e 100644 --- a/lib/galaxy/jobs/handler.py +++ b/lib/galaxy/jobs/handler.py @@ -6,6 +6,7 @@ import os import time import logging import threading +import datetime from Queue import Queue, Empty from sqlalchemy.sql.expression import and_, or_, select, func, true, null @@ -375,6 +376,33 @@ class JobHandlerQueue( object ): # job is ready to run, check limits # TODO: these checks should be refactored to minimize duplication and made more modular/pluggable state = self.__check_destination_jobs( job, job_wrapper ) + + # Check + jobs_to_check = self.sa_session.query( model.Job ).filter( + model.Job.user_id == job.user.id, + model.Job.update_time >= + datetime.datetime.now() - datetime.timedelta(30), + model.Job.state == 'ok' + ).all() + time_spent = datetime.timedelta(0) + for job in jobs_to_check: + # History is job.state_history + started = None + finished = None + for history in sorted( + job.state_history, + key=lambda history: history.update_time): + if history.state == "running": + started = history.create_time + elif history.state == "ok": + finished = history.create_time + + time_spent += finished - started + + if time_spent > datetime.timedelta(seconds=20): + log.debug("Used too much cpu time") + + if state == JOB_READY: state = self.__check_user_jobs( job, job_wrapper ) if state == JOB_READY and self.app.config.enable_quotas: From 2408502c2d316869df0f84b65e50db3114f9529a Mon Sep 17 00:00:00 2001 From: Maximilian Friedersdorff Date: Thu, 24 Nov 2016 16:59:54 +0000 Subject: [PATCH 2/7] Add total_walltime limit type Add to sample config, config reader and unittest --- config/job_conf.xml.sample_advanced | 7 +++++++ lib/galaxy/jobs/__init__.py | 16 ++++++++++++++++ test/unit/jobs/test_job_configuration.py | 3 +++ 3 files changed, 26 insertions(+) diff --git a/config/job_conf.xml.sample_advanced b/config/job_conf.xml.sample_advanced index 4192008e45e..ca8c22aae33 100644 --- a/config/job_conf.xml.sample_advanced +++ b/config/job_conf.xml.sample_advanced @@ -762,6 +762,13 @@ will be terminated by Galaxy. --> 24:00:00 + + 24:00:00 24:00:00 24:00:00