Skip to content

Commit

Permalink
Disable ShellcmdLrms resources if capacity is exceeded.
Browse files Browse the repository at this point in the history
This is implemented by having the resource raise a
`MaximumCapacityExceeded` exception, to which the scheduler reacts by
dropping the resource for the current cycle.
  • Loading branch information
riccardomurri committed Jan 16, 2018
1 parent cea37ee commit 343700f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions gc3libs/backends/shellcmd.py
@@ -1,5 +1,5 @@
#! /usr/bin/env python
# Copyright (C) 2009-2017 University of Zurich. All rights reserved.
# Copyright (C) 2009-2018 University of Zurich. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -1378,19 +1378,19 @@ def _check_app_requirements(self, app, update=True):

if self.free_slots == 0: # or free_slots == 0:
if self.override:
raise gc3libs.exceptions.LRMSSubmitError(
raise gc3libs.exceptions.MaximumCapacityReached(
"Resource {0} already running maximum allowed number of jobs"
.format(self.name))
else:
raise gc3libs.exceptions.LRMSSubmitError(
raise gc3libs.exceptions.MaximumCapacityReached(
"Resource %s already running maximum allowed number of jobs"
" (%s). Increase 'max_cores' to raise." %
(self.name, self.max_cores))

if app.requested_memory:
total_requested_memory = app.requested_cores * app.requested_memory
if self.available_memory < total_requested_memory:
raise gc3libs.exceptions.LRMSSubmitError(
raise gc3libs.exceptions.MaximumCapacityReached(
"Resource {0} does not have enough available memory:"
" {1} requested total, but only {2} available."
.format(
Expand Down
7 changes: 4 additions & 3 deletions gc3libs/core.py
Expand Up @@ -1101,13 +1101,14 @@ def first_come_first_serve(tasks, resources, matchmaker=MatchMaker()):
try:
# result = yield (task_idx, target.name)
yield (task_idx, target.name)
except gc3libs.exceptions.ResourceNotReady:
except (gc3libs.exceptions.ResourceNotReady,
gc3libs.exceptions.MaximumCapacityReached) as exc:
# this is not a real error: the resource is adapting
# for the task and will actually accept it sometime in
# the future, so disable resource and try next one
gc3libs.log.debug(
"Disabling resource `%s` for this scheduling cycle",
target.name)
"Disabling resource `%s` for this scheduling cycle: %s",
target.name, exc)
resources.remove(target)
continue
# pylint: disable=broad-except
Expand Down
3 changes: 2 additions & 1 deletion gc3libs/exceptions.py
Expand Up @@ -111,7 +111,7 @@ def __init__(self, msg, do_log=True):
Exception.__init__(self, msg)


# derived exceptions
## derived exceptions

class AuthError(Error):

Expand Down Expand Up @@ -322,6 +322,7 @@ def __init__(self, msg, do_log=False):
DeprecationWarning, 2)
super(LRMSSkipSubmissionToNextIteration, self).__init__(msg, do_log)


class MaximumCapacityReached(LRMSSubmitError, RecoverableError):

"""
Expand Down

0 comments on commit 343700f

Please sign in to comment.