FORGE-79: autoscale the Cloudflare executor from waiting jobs #694
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!694
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "FORGE-79-executor-pool"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Issue: https://tasks.gmac.io/gmacko/issue/FORGE-79 · plan phase 3 · follows #686
What
CiExecutorPoolDurable Object (singleton) with an alarm loop everyPOOL_POLL_SECONDS(20). Each tick:cloudflarelabel can run, viaGET /api/v1/repos/gmackie/ForgeGraph/actions/runners/jobs?labels=cloudflare, with a read-only token (read:repository; writes return 403);planLaunches.planLaunches(pure,src/plan.ts): launches from the last 90s count as already claiming, so a slow claim doesn't start a second container, and at mostPOOL_MAX_IN_FLIGHT(6) starts are in flight. Sixnode:testcases cover it (pnpm --filter @forgegraph/ci-executor test).* * * * *acts only as a keep-alive that restarts the alarm loop.GET /pool(admin bearer) shows recent launches and the last tick.max_instancesgoes 4 → 8. The container also receivesRUNNER_LABEL.Why the Forgejo API
It needs no SSH or psql against the busy Forgejo host, and it is one small API call per poll. When FORGE-67's control plane serves the same job search, or pushes to the pool, only the URL or trigger changes.
Verified live (deployed from this branch)
/poolshowedpending: 0while idle. After dispatchingcf-executor-smoke, the next tick (9s later) sawpending: 1and started one container, which claimed the job. Run #3434 passed in 10s, with no manual/run.Not in this PR
Phase 4 (routing light
ci.ymljobs tocloudflare) follows separately.🤖 Generated with Claude Code
CiExecutorPool, a singleton Durable Object, polls Forgejo's runner job search (GET /repos/{repo}/actions/runners/jobs?labels=cloudflare) every 20s with a read-only token. It starts one container per waiting task. Launches from the last 90s count as already claiming, so a slow claim does not double up, and at most 6 starts are in flight. A per-minute cron restarts the alarm loop if it ever stops. GET /pool (admin) shows the last tick. It uses Forgejo's public API, not its database, so the loop needs no SSH or psql and can follow FORGE-67's control plane once that serves the same query or pushes. The planner is a pure function with node:test coverage. max_instances goes to 8. Verified live: a dispatched cf-executor-smoke run was seen as pending, a container was started without a manual /run, and run #3434 passed in 10s. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>Preview environment is live: https://pr-694-forgegraph.forgegraf.com
Deployed
da2cce31with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.