Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Scheduler parameters #349

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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