alter priority policy result syntax, catch ValueError

This commit is contained in:
Mike McLean 2021-01-29 10:55:47 -05:00 committed by Tomas Kopecek
parent 1d69126589
commit 1f884a3287
2 changed files with 6 additions and 7 deletions

View file

@ -178,10 +178,10 @@ different:
``set <int>``
* set priority to this value
``increment by <int>``
``adjust +<int>``
* increment default priority
``decrement by <int>``
``adjust -<int>``
* decrement default priority
Available tests

View file

@ -606,14 +606,13 @@ def make_task(method, arglist, **opts):
elif parts[0] == 'set':
# fixed value
opts['priority'] = int(parts[1])
elif parts[0] == 'increment' and parts[1] == 'by':
opts['priority'] += int(parts[2])
elif parts[0] == 'decrement' and parts[1] == 'by':
opts['priority'] -= int(parts[2])
elif parts[0] == 'adjust':
# note: int() will accept our preferred "+1" representation for increments
opts['priority'] += int(parts[1])
else:
logger.error("Invalid result from priority policy: %s", ruleset.last_rule())
raise koji.GenericError("invalid priority policy")
except IndexError:
except (IndexError, ValueError):
logger.error("Invalid result from priority policy: %s", ruleset.last_rule())
raise koji.GenericError("invalid priority policy")