Skip to content

Commit

Permalink
Clients: enforce rucio update-rule --cancel-requests to specify a state
Browse files Browse the repository at this point in the history
#3838

`rucio update-rule --cancel-reqeusts` needs a state to determine its
utilization. Right now the program exits normaly without any error if no state
is given, letting the user believe everything worked out.

This commit enforces the specification of a state, with `--stuck` or
`--suspend`. If no state is given, the program exits with an error.
  • Loading branch information
Joel Dierkes authored and bari12 committed Oct 11, 2021
1 parent 7fab9b7 commit 5dbde39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bin/rucio
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
# - Christoph Ames <christoph.ames@physik.uni-muenchen.de>, 2021
# - James Perry <j.perry@epcc.ed.ac.uk>, 2021
# - David Población Criado <david.poblacion.criado@cern.ch>, 2021
# - Joel Dierkes <joel.dierkes@cern.ch>, 2021

from __future__ import print_function

Expand Down Expand Up @@ -1339,6 +1340,9 @@ def update_rule(args):
if args.source_replica_expression:
options['source_replica_expression'] = None if args.source_replica_expression.lower() == 'none' else args.source_replica_expression
if args.cancel_requests:
if 'state' not in options:
logger.error('--stuck or --suspend must be specified when running --cancel-requests')
return FAILURE
options['cancel_requests'] = True
if args.priority:
options['priority'] = int(args.priority)
Expand Down
8 changes: 8 additions & 0 deletions lib/rucio/tests/test_bin_rucio.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# - Rahul Chauhan <omrahulchauhan@gmail.com>, 2021
# - Simon Fayer <simon.fayer05@imperial.ac.uk>, 2021
# - David Población Criado <david.poblacion.criado@cern.ch>, 2021
# - Joel Dierkes <joel.dierkes@cern.ch>, 2021

from __future__ import print_function

Expand Down Expand Up @@ -1723,3 +1724,10 @@ def test_upload_recursive_only_files(self):
assert re.search("DATASET", out) is not None
cmd = 'rm -rf %s' % folder
execute(cmd)

def test_update_rule_cancel_requests_args(self):
"""CLIENT(USER): update rule cancel requests must have a state defined"""
cmd = 'rucio update-rule --cancel-requests RULE'
exitcode, out, err = execute(cmd)
assert '--stuck or --suspend must be specified when running --cancel-requests' in err
assert exitcode != 0

0 comments on commit 5dbde39

Please sign in to comment.