Skip to content

Commit

Permalink
Merge pull request #2712 from dchristidis/patch-2701-Lifetime_Model__…
Browse files Browse the repository at this point in the history
…Add___purge_replicas_command_line_option

Lifetime Model: Add --purge-replicas command-line option #2701
  • Loading branch information
bari12 committed Jul 5, 2019
2 parents 707ef41 + 719dddb commit b0943e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion bin/rucio-atropos
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def get_parser():
parser.add_argument("--date-check", action="store", help='Date when the lifetime model will be applied. Cannot be used for a date in the future if dry-run is not enabled')
parser.add_argument("--unlock-rules", action="store_true", default=False, help='Automatically unlock affected rules')
parser.add_argument("--spread-period", action="store", default=0, type=int, help='Set the rules to randomly expire over a period (in seconds). Uses a uniform distribution')
parser.add_argument("--purge-replicas", action="store_true", default=False, help='Set the replicas to be deleted instead of secondarised')
return parser


Expand All @@ -57,6 +58,7 @@ if __name__ == "__main__":
run(threads=args.threads, bulk=args.bulk, date_check=args.date_check,
dry_run=args.dry_run, grace_period=args.grace_period,
once=args.run_once, unlock=args.unlock_rules,
spread_period=args.spread_period)
spread_period=args.spread_period,
purge_replicas=args.purge_replicas)
except KeyboardInterrupt:
stop()
9 changes: 6 additions & 3 deletions lib/rucio/daemons/atropos/atropos.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@


def atropos(thread, bulk, date_check, dry_run=True, grace_period=86400,
once=True, unlock=False, spread_period=0):
once=True, unlock=False, spread_period=0, purge_replicas=False):
"""
Creates an Atropos Worker that gets a list of rules which have an eol_at expired and delete them.
Expand Down Expand Up @@ -150,6 +150,8 @@ def atropos(thread, bulk, date_check, dry_run=True, grace_period=86400,
lifetime = grace_period + rand.randrange(spread_period + 1)
logging.info(prepend_str + 'Setting %s seconds lifetime for rule %s' % (lifetime, rule.id))
options = {'lifetime': lifetime}
if purge_replicas:
options = {'purge_replicas': True}
if rule.locked and unlock:
logging.info(prepend_str + 'Unlocking rule %s', rule.id)
options['locked'] = False
Expand Down Expand Up @@ -185,7 +187,7 @@ def atropos(thread, bulk, date_check, dry_run=True, grace_period=86400,


def run(threads=1, bulk=100, date_check=None, dry_run=True, grace_period=86400,
once=True, unlock=False, spread_period=0):
once=True, unlock=False, spread_period=0, purge_replicas=False):
"""
Starts up the atropos threads.
"""
Expand All @@ -203,7 +205,8 @@ def run(threads=1, bulk=100, date_check=None, dry_run=True, grace_period=86400,
'grace_period': grace_period,
'bulk': bulk,
'unlock': unlock,
'spread_period': spread_period}) for i in range(0, threads)]
'spread_period': spread_period,
'purge_replicas': purge_replicas}) for i in range(0, threads)]
[t.start() for t in thread_list]

logging.info('waiting for interrupts')
Expand Down

0 comments on commit b0943e4

Please sign in to comment.