Skip to content

Commit

Permalink
Upgrade spreaper with recently added features
Browse files Browse the repository at this point in the history
The force, adaptive and percentUnrepairedThreshold recently added arguments for repairs and schedules were missing from spreaper operations, which this commit fixes.
  • Loading branch information
adejanovski committed Mar 14, 2022
1 parent 11de7b9 commit 6490c67
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/packaging/bin/spreaper
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ def _arguments_for_repair_and_schedule(parser):
"within the keyspace (do not use spaces after commas)"))
parser.add_argument("--repair-threads", default=1,
help=("The number of threads to use in Cassandra to parallelize repair sessions (from 1 to 4)"))
parser.add_argument("--force", default=False, action='store_true',
help=("Force create the repair/schedule even if there is a conflicting repair that was created previously."))


def _arguments_for_scheduling(parser):
Expand All @@ -256,6 +258,10 @@ def _arguments_for_scheduling(parser):
parser.add_argument("--schedule-trigger-time", default=None,
help="at which time to trigger the first repair (UTC), "
"e.g. \"2015-02-10T15:00:00\"")
parser.add_argument("--adaptive", default=False, action='store_true',
help=("Create an adaptive repair schedule."))
parser.add_argument("--percent-unrepaired-threshold", default=None,
help=("Percent of unrepaired data to trigger repair run for incremental repair schedules."))
_argument_owner(parser)


Expand Down Expand Up @@ -731,7 +737,8 @@ class ReaperCLI(object):
nodes=args.nodes,
datacenters=args.datacenters,
blacklistedTables=args.blacklisted_tables,
repairThreadCount=args.repair_threads)
repairThreadCount=args.repair_threads,
force="true" if args.force else "false")
else:
if args.blacklisted_tables :
printq ("# Registering repair run for cluster '{0}', and keyspace '{1}', "
Expand All @@ -751,7 +758,8 @@ class ReaperCLI(object):
nodes=args.nodes,
datacenters=args.datacenters,
blacklistedTables=args.blacklisted_tables,
repairThreadCount=args.repair_threads)
repairThreadCount=args.repair_threads,
force="true" if args.force else "false")
repair_run = json.loads(reply)
printq("# Repair run with id={0} created".format(repair_run.get('id')))
if not args.dont_start_repair:
Expand Down Expand Up @@ -792,7 +800,10 @@ class ReaperCLI(object):
nodes=args.nodes,
datacenters=args.datacenters,
blacklistedTables=args.blacklisted_tables,
repairThreadCount=args.repair_threads)
repairThreadCount=args.repair_threads,
force="true" if args.force else "false",
adaptive="true" if args.adaptive else "false",
percentUnrepairedThreshold=args.percent_unrepaired_threshold)
else:
printq ("# Registering repair schedule for cluster '{0}', and keyspace '{1}', "
"targeting all tables in the keyspace, with scheduled days between "
Expand All @@ -810,7 +821,10 @@ class ReaperCLI(object):
nodes=args.nodes,
datacenters=args.datacenters,
blacklistedTables=args.blacklisted_tables,
repairThreadCount=args.repair_threads)
repairThreadCount=args.repair_threads,
force="true" if args.force else "false",
adaptive="true" if args.adaptive else "false",
percentUnrepairedThreshold=args.percent_unrepaired_threshold)
repair_schedule = json.loads(reply)
printq("# Repair schedule with id={0} created:".format(repair_schedule.get('id')))
print(json.dumps(repair_schedule, indent=2, sort_keys=True))
Expand Down

0 comments on commit 6490c67

Please sign in to comment.