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

SW-426: fixed scheduler tests

parent 372c1ed2
No related branches found
No related tags found
No related merge requests found
......@@ -377,11 +377,12 @@ class ResourceAvailabilityChecker(object):
res_group = self.resource_group_relations[gids[i]]
for rid in res_group['resource_ids']:
if rid in available_recources:
type_id = available_recources[rid]['type_id']
if type_id in needed_resources_by_type_id and available_recources[rid]['active'] and \
available_recources[rid]['available_capacity'] > 0:
resources[type_id] = available_recources[rid]
type_ids_seen.add(type_id)
available_recource = available_recources[rid]
type_id = available_recource['type_id']
if type_id in needed_resources_by_type_id and available_recource['active']:
if available_recource['available_capacity'] > 0:
resources[type_id] = available_recource
type_ids_seen.add(type_id)
else:
logger.debug("requested resource id %s is not available/claimable", rid)
......
from datetime import datetime, timedelta
from copy import deepcopy
from lofar.common.cache import cache
......@@ -111,8 +112,11 @@ class BasicScheduler(object):
allocation_successful = True
except ScheduleException, e:
logger.exception("BasicScheduler: scheduling threw exception: %s", e)
logger.exception("%s: scheduling threw ScheduleException: %s", self.__class__.__name__, e)
self._handle_schedule_exception()
except Exception, e:
logger.exception("%s: scheduling threw unhandled exception: %s", self.__class__.__name__, e)
raise
return allocation_successful
......@@ -414,13 +418,17 @@ class StationScheduler(BasicScheduler):
wanted_estimates = self._get_station_estimates()
# Try to schedule all of the stations.
remaining_estimates = self._schedule_resources(wanted_estimates, available_resources, need_all=False)
# make a (deep)copy of available_resources and use that,
# because _schedule_resources modifies the available_capacity of the tested wanted stations.
# we rollback the radb later in this method, so we should keep the original available_resources intact.
available_resources_copy = deepcopy(available_resources)
remaining_estimates = self._schedule_resources(wanted_estimates, available_resources_copy, need_all=False)
# See if our allocation meets the minimal criteria. Note that some stations may be partially allocated,
# we do not count those as claimable.
unclaimable_stations = set([e["station"] for e in remaining_estimates])
if not self._requirements_satisfied_without(expanded_requirements, unclaimable_stations):
raise ScheduleException("Could not allocate enough stations")
raise ScheduleException("Could not allocate enough stations. unclaimable_stations=%s" % (unclaimable_stations,))
allocated_stations = set([e["station"] for e in wanted_estimates if e not in remaining_estimates])
......@@ -635,7 +643,7 @@ class PriorityScheduler(StationScheduler):
"""
if conflict_claim["resource_type_id"] == self.resource_availability_checker.resource_types['storage']:
raise ScheduleException("Could not resolve conflict on storage resource")
raise ScheduleException("Cannot resolve conflict on storage resource")
# find all conflicting claims & which tasks they belong to
conflicting_claims, conflicting_tasks = self._get_conflicting_claims_and_tasks(conflict_claim)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment