From a334d7c3c33ec0246d9a13b0369742988df8bbb9 Mon Sep 17 00:00:00 2001 From: Vijay Chakravarty Date: Mon, 14 Oct 2024 09:56:10 +0200 Subject: [PATCH] adding dryrun option for task scheduling (#8734) * adding dryrun option for task scheduling * Handle absence of dry_run option * General exception pylint disable * add getattr and httpexception --- src/python/TaskWorker/Main.py | 4 +--- src/python/TaskWorker/MasterWorker.py | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/python/TaskWorker/Main.py b/src/python/TaskWorker/Main.py index 20a14785bf..f6f0d1963e 100644 --- a/src/python/TaskWorker/Main.py +++ b/src/python/TaskWorker/Main.py @@ -71,9 +71,7 @@ def main(): raise ConfigException("Configuration not found") configuration = loadConfigurationFile(os.path.abspath(options.config)) - configuration.section_('TaskScheduling') - configuration.TaskScheduling.selection_limit = 10 - configuration.TaskScheduling.dry_run= True + status, msg = validateConfig(configuration) if not status: raise ConfigException(msg) diff --git a/src/python/TaskWorker/MasterWorker.py b/src/python/TaskWorker/MasterWorker.py index 34e82c6b4f..9ee3544c04 100644 --- a/src/python/TaskWorker/MasterWorker.py +++ b/src/python/TaskWorker/MasterWorker.py @@ -313,13 +313,18 @@ def _externalScheduling(self, limit): # Log the formatted table self.logger.info('\n%s', table) - if self.config.TaskScheduling.dry_run: - return selected_tasks #dry_run True (with Task Scheduling) - else: - return waiting_tasks #dry_run False (without Task Scheduling) + if getattr(self.config.TaskWorker, 'task_scheduling_dry_run', False): + return waiting_tasks + return selected_tasks - except Exception as e: - self.logger.exception("Exception occurred during external scheduling: %s", str(e)) + except HTTPException as hte: + msg = "HTTP Error during external scheduling: %s\n" % str(hte) + msg += "HTTP Headers are %s: " % hte.headers + self.logger.error(msg) + return [] + + except Exception as e: #pylint: disable=broad-except + self.logger.exception("Unknown Exception occurred during external scheduling: %s", str(e)) return [] def _pruneTaskQueue(self): @@ -519,7 +524,7 @@ def algorithm(self): self.restartQueuedTasks() self.logger.debug("Master Worker Starting Main Cycle.") while not self.STOP: - selection_limit = self.config.TaskScheduling.selection_limit + selection_limit = self.config.TaskWorker.task_scheduling_limit if not self._selectWork(limit=selection_limit): self.logger.warning("Selection of work failed.") else: