feat: Add GitHub Actions Runner Scale Set integration#253
Open
whywaita wants to merge 6 commits into
Open
Conversation
Add support for scale set mode as an alternative to webhook mode. Scale set mode uses long-polling to GitHub Scale Set API instead of receiving webhook events, enabling faster runner provisioning with JIT (Just-In-Time) configuration. Key changes: - Add scaleset package with manager, scaler, and JIT script generation - Add SCALESET_* environment variables for configuration - Integrate scale set manager into server startup - Add comprehensive tests and documentation - Support both webhook and scale set modes via SCALESET_ENABLED flag prompt: Implement the following plan: # Scale Set Client Integration Plan ... ---- 了解した。Scale Set Client統合プランの実装を開始する。 段階的に実装を進める。まず基盤となるConfigから着手し、scaleset パッケージを構築、Server統合、テスト、ドキュメントの順序で進行する。 ## Step 1: 依存追加 ... ---- (implementation details)
Fix four critical issues identified in code review: P1 Issues: 1. Remove stopped listeners from scaler map - Add defer cleanup in listener goroutine to remove from m.scalers - Prevents stale entries that block target restart after errors 2. Disable webhook enqueue in scale set mode - Add scaleSetEnabled parameter to NewMux - Skip /github/events registration when scale set mode enabled - Prevents job queue accumulation from unused webhooks 3. Preserve runner state on instance deletion failure - Return error when DeleteInstance fails - Keep runner in activeRunners for retry on transient errors - Prevents orphaned instances from untracked failures P2 Issues: 4. Refresh scaler when target config changes - Add targetConfigChanged() to detect config updates - Restart listener when ResourceType/ProviderURL/Status changes - Ensures API-driven target updates take effect immediately All tests pass and builds successfully.
…b completion Guard deferred cleanup in startListener from deleting a replacement wrapper stored by syncTargets during config-change restarts. The defer now checks pointer identity before removing the map entry. Fall back to datastore lookup in HandleJobCompleted when activeRunners (in-memory) does not contain the runner, preventing instance and datastore row leaks after process restarts or listener re-creation.
The GitHub API returns a 400 ArgumentNullException when creating scale
sets because Label.Type was set to invalid enum values ("scaleset",
"scope"). Leave Type empty so the library defaults to "System", matching
the official actions/scaleset examples.
Also adds RunnerSetting{DisableUpdate: true} and removes the redundant
RunnerGroupName field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
pkg/scaleset: Manager, scaler, JIT script generation, and metricsSCALESET_*environment variables for scale set configurationSCALESET_ENABLEDflagdocs/scaleset-mode.mdKey Components
pkg/scaleset/manager.go): Manages scale set lifecycle for all targetspkg/scaleset/scaler.go): Implementslistener.Scalerinterface for runner provisioningpkg/scaleset/scripts.go): Generates simplified setup scripts for JIT runnerspkg/scaleset/metrics.go): 5 Prometheus metrics for monitoring scale set operationsArchitecture Changes
Webhook Mode (existing):
Scale Set Mode (new):
Configuration
Enable scale set mode with environment variables:
GitHub App Permissions
New requirement for Organization-level targets:
organization_self_hosted_runners: Read & WriteRepository-level targets continue to work with existing permissions.
Test Plan
go test ./pkg/scaleset/...✅go test ./...✅go build ./...✅go fmt ./...✅Manual Testing
To test scale set mode:
SCALESET_ENABLED=trueand otherSCALESET_*variablesorganization_self_hosted_runnerspermission (for org-level targets)/metricsendpoint formyshoes_scaleset_*metricsNotes
GITHUB_URLconfigurationFor detailed documentation, see
docs/scaleset-mode.md.