Skip to content

SG-4024: Add MAX_RUNNERS constraint.#13

Open
hllvc wants to merge 2 commits intomainfrom
SG-4024-max-runners
Open

SG-4024: Add MAX_RUNNERS constraint.#13
hllvc wants to merge 2 commits intomainfrom
SG-4024-max-runners

Conversation

@hllvc
Copy link
Collaborator

@hllvc hllvc commented Jan 12, 2026

Adds a MAX_RUNNERS constraint to the sg-runner-autoscaler to cap concurrent runner provisioning. This aligns with StackGuardian’s ongoing capacity and cost controls for CI runner usage under SG-4024.

Changes

  • MAX_RUNNERS config: Introduces a new constraint to limit the total number of concurrently provisioned runners; acts as a hard ceiling in scaling decisions.
  • Scaling logic enforcement: Validates desired scale against MAX_RUNNERS before provisioning or queuing new runners, preventing burst-induced over-allocation.
  • Behavioral defaults: When MAX_RUNNERS is unset, autoscaler behaves as before (no cap); when set to an integer, the ceiling is enforced consistently.
  • Edge-case handling: Ensures correct behavior under job bursts, cooldowns, and queue backpressure; avoids thrashing at the boundary.
  • Configuration surface: Adds parsing/support for configuration (env/params) so ops can tune caps per environment/org.
  • Refactor/cleanup: Minor adjustments around the scaling path to centralize cap checks and reduce duplication.
  • Scope of diff: +43 / −16 in one file; focused change set to introduce and enforce the constraint.

Testing

No tests or manual verification are included in the PR as visible here.

@hllvc hllvc requested a review from taherkk January 12, 2026 11:14
@hllvc hllvc self-assigned this Jan 12, 2026
@notion-workspace
Copy link

if self.MAX_RUNNERS >= 0 and self.MAX_RUNNERS < self.MIN_RUNNERS:
logging.warning(
f"MAX_RUNNERS ({self.MAX_RUNNERS}) is less than MIN_RUNNERS ({self.MIN_RUNNERS})"
)
Copy link
Collaborator

@taherkk taherkk Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is the case you should exit immediately. This invalid configuration

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exit instead of warning

@hllvc hllvc force-pushed the SG-4024-max-runners branch from 6aa0d9d to 7e6d3c0 Compare February 24, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants