Skip to content
Snippets Groups Projects
Commit 85bed6e9 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

SW-786: raise ScheduleException upon radb PostgresDBQueryExecutionError

parent 3dc6e613
No related branches found
No related tags found
2 merge requests!20Lofar release 4 0 back to master,!17Resolve SW-786
......@@ -72,9 +72,11 @@ def movePipelineAfterItsPredecessors(task, radbrpc, min_start_timestamp=None):
if shift != timedelta(seconds=0):
logger.info("Moving %s pipeline radb_id=%s otdb_id=%s by %s from \'%s\' to \'%s\'", task['status'], task['id'], task['otdb_id'], format_timedelta(shift), task['starttime'], newStartTime)
if not radbrpc.updateTaskAndResourceClaims(task['id'], starttime=newStartTime, endtime=newEndTime):
logger.warning("Could not update start/endtime for pipeline radb_id=%s otdb_id=%s",
updated_task['id'], updated_task['otdb_id'])
try:
radbrpc.updateTaskAndResourceClaims(task['id'], starttime=newStartTime, endtime=newEndTime)
except Exception as e:
logger.warning("Could not update start/endtime for pipeline radb_id=%s otdb_id=%s error: %s",
task['id'], task['otdb_id'], e)
updated_task = radbrpc.getTask(task['id'])
......@@ -143,7 +145,12 @@ class ScheduleChecker():
if task['endtime'] <= now:
new_endtime=now+timedelta(seconds=PIPELINE_CHECK_INTERVAL)
logger.info("Extending endtime to %s for pipeline radb_id=%s otdb_id=%s", new_endtime, task['id'], task['otdb_id'])
try:
self._radbrpc.updateTaskAndResourceClaims(task['id'], endtime=new_endtime)
except Exception as e:
logger.error("Could not extend endtime to %s for pipeline radb_id=%s otdb_id=%s error: %s",
new_endtime, task['id'], task['otdb_id'], e)
except Exception as e:
logger.error("Error while checking running pipelines: %s", e)
......
......@@ -4,7 +4,7 @@ from copy import deepcopy
from lofar.common.cache import cache
from lofar.messaging import DEFAULT_BROKER, DEFAULT_BUSNAME
from lofar.sas.resourceassignment.database.radb import RADatabase
from lofar.sas.resourceassignment.database.radb import RADatabase, PostgresDBQueryExecutionError
from lofar.mom.momqueryservice.momqueryrpc import MoMQueryRPC
......@@ -153,8 +153,11 @@ class BasicScheduler(object):
logger.debug("BasicScheduler: _post_process_allocation for task %s", self.task_id)
# move all claims from tentative -> claimed
try:
if not self.radb.updateResourceClaims(where_task_ids=[self.task_id], status="claimed", commit=False):
raise ScheduleException("Failed to put tentative claims to claimed")
except PostgresDBQueryExecutionError as e:
raise ScheduleException("Failed to put tentative claims to claimed. error: %s" % (e,))
changed_tasks = [] #Not used in the BasicScheduler, but in derived schedulers it is
return changed_tasks
......@@ -234,6 +237,7 @@ class BasicScheduler(object):
:raises ScheduleException if it could not schedule the resources due to conflicts
"""
try:
logger.debug("Requested resources: %s", requested_resources)
logger.debug("Available resources: %s", available_resources)
......@@ -294,6 +298,8 @@ class BasicScheduler(object):
logger.info("Remaining estimates: %s", remaining_estimates)
return remaining_estimates
except PostgresDBQueryExecutionError as e:
raise ScheduleException("Error while scheduling resources: %s" % (e,))
def _resolve_conflict(self, conflict_claim):
""" Resolve one conflict, making it is useful to try to schedule again.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment