feat(control-plane): cron-triggered wake/poll orchestration for hosted AMS tenants - #8075
Merged
Merged
Conversation
…d AMS tenants (#7182) Adds ams-wake.ts: a Cloudflare Cron Trigger scheduled() handler (wrangler.jsonc, every 5 minutes -- there is no per-resource cron primitive, so per-tenant cadence lives as data on each AMS tenant's own amsSchedule) that finds every currently-due AMS tenant, wakes its container via the already-shipped loopover-miner-hosted entry point (an explicit entrypoint override, not HTTP), polls for its real exit code, and records the result -- 0=success, 2=failure, unmodified, per docs/unattended-scheduling.md's existing contract. Distinguishes a genuine poll timeout from a container that legitimately stopped without reporting a code (both leave exitCode undefined, but only one is actually a timeout). POST /v1/tenants gains an optional `schedule` field (command/args/intervalMs, AMS-only) to configure a new tenant's cadence at creation time; GET /v1/tenants surfaces it back for admin visibility. Sequential (not concurrent) wake processing, since a single Cron Trigger invocation has a bounded wall-clock budget shared across every due tenant that tick. This is the control-plane half of #7182 (the miner-side hosted entry point, loopover-miner-hosted, already shipped separately) -- brings #7180's provisioning core's downstream consumers to their full intended shape for AMS, alongside #7181 (ORB webhook routing, not yet built) for the ORB side.
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8075 +/- ##
==========================================
+ Coverage 91.96% 92.50% +0.53%
==========================================
Files 747 665 -82
Lines 76408 55934 -20474
Branches 23211 19585 -3626
==========================================
- Hits 70269 51742 -18527
+ Misses 5039 3317 -1722
+ Partials 1100 875 -225
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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
Control-plane half of #7182 (the miner-side hosted entry point,
loopover-miner-hosted, already shipped in #8070). Together they bring #7180's provisioning core to its full intended shape for AMS.ams-wake.ts: ascheduled()handler (Cloudflare Cron Trigger, every 5 minutes) that finds every currently-due AMS tenant and wakes it. There's no per-resource Cron Trigger primitive, so per-tenant cadence lives as data on each tenant's ownamsSchedulerecord, checked by one frequent global tick.entrypointoverride (not HTTP) callingloopover-miner-hosted, then pollsgetState()for its real exit code (0=success, 2=failure, perdocs/unattended-scheduling.md's existing contract) and records it, unmodified.exitCodeundefined, but only one is a timeout.POST /v1/tenantsgains an optionalschedulefield (command/args/intervalMs, AMS-only) to configure a new tenant's cadence at creation time;GET /v1/tenantssurfaces it back for admin visibility.Test plan
npm run build(typecheck) cleannpm run cf:typecheckcleannpm run test:node— 129/129 passingnode ../scripts/control-plane-coverage.mjs— 99.93%/99.38%/98.83%/99.93% (only gap: pre-existing, untouchedsettlement-backend-driver.ts)npx wrangler deploy --dry-runclean, both container images build, all bindings resolveCloses #7182