Skip to content

Commit

Permalink
Merge pull request #349 from HebaruSan/fix/scheduler-params
Browse files Browse the repository at this point in the history
Refactor Scheduler parameters
  • Loading branch information
HebaruSan authored Oct 31, 2024
2 parents 2045c78 + 9fc1378 commit 47341ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 12 additions & 7 deletions netkan/netkan/cli/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ def indexer(common: SharedArgs) -> None:


@click.command(short_help='The Scheduler service')
@click.option(
'--max-queued', default=20, envvar='MAX_QUEUED',
help='SQS Queue to send netkan metadata for scheduling',
)
@click.option(
'--group',
type=click.Choice(['all', 'webhooks', 'nonhooks']), default="nonhooks",
help='Which mods to schedule',
)
@click.option(
'--max-queued', default=20, envvar='MAX_QUEUED',
help='Only schedule if the inflation queue already has fewer than this many messages',
)
@click.option(
'--min-cpu', default=200,
help='Only schedule if we have at least this many CPU credits remaining',
Expand All @@ -39,14 +39,19 @@ def indexer(common: SharedArgs) -> None:
'--min-io', default=70,
help='Only schedule if we have at least this many IO credits remaining',
)
@click.option(
'--min-gh', default=1500,
help='Only schedule if our GitHub API rate limit has this many remaining',
)
@common_options
@pass_state
def scheduler(
common: SharedArgs,
max_queued: int,
group: str,
max_queued: int,
min_cpu: int,
min_io: int
min_io: int,
min_gh: int
) -> None:
"""
Reads netkans from a NetKAN repo and submits them to the
Expand All @@ -59,7 +64,7 @@ def scheduler(
nonhooks_group=(group in ('all', 'nonhooks')),
webhooks_group=(group in ('all', 'webhooks')),
)
if sched.can_schedule(max_queued, common.dev, min_cpu, min_io):
if sched.can_schedule(max_queued, min_cpu, min_io, min_gh, common.dev):
sched.schedule_all_netkans()
logging.info("NetKANs submitted to %s", game.inflation_queue)

Expand Down
4 changes: 2 additions & 2 deletions netkan/netkan/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ def volume_credits_percent(cloudwatch: CloudWatchClient, instance_id: str,
logging.error("Couldn't acquire Volume Credit Stats")
return creds

def can_schedule(self, max_queued: int, dev: bool = False,
min_cpu: int = 50, min_io: int = 70, min_gh: int = 1500) -> bool:
def can_schedule(self, max_queued: int, min_cpu: int, min_io: int, min_gh: int,
dev: bool = False) -> bool:
if not dev:
github_remaining = github_limit_remaining(self.github_token)
if github_remaining < min_gh:
Expand Down

0 comments on commit 47341ae

Please sign in to comment.