Repository navigation
feat: optional fire-and-forget spot-interruption webhook (#228) - #229
Merged
Merged
Conversation
Adds `spawn launch --spot-webhook-url <url>`: on an AWS spot interruption
notice, spored fires a single best-effort POST so an off-node consumer learns
about the reclamation inside the ~2-minute window — which the tag-and-poll
surface structurally cannot deliver.
The payload is a fixed projection of on-node facts (instance/region/az, the AWS
`action`, the interruption deadline, accumulated compute-seconds, last-activity)
plus an opaque `--webhook-correlation` blob echoed back verbatim for the consumer
to correlate against its own record. Per the issue review, the payload does NOT
carry the RunInstances ClientToken: it isn't on-node (spored's config comes from
spawn:* tags + IMDS), so correlation rides on the opaque echo instead — keeping
spawn fully consumer-agnostic.
Stays in-grain (fire-and-forget, never awaits):
- fire-once (the spot monitor re-enters every 5s), no retry
- `--webhook-timeout` (default 2s) hard-caps the POST
- fired LAST in checkSpotInterruption, after the file notification, so a slow
or dead endpoint can't delay Cleanup/pre-stop/the survival work (#65 discipline)
- failure (disabled, timeout, DNS, non-2xx) is logged at most and dropped; the
EC2 state + spawn:* tags remain the durable source of truth
- opt-in: empty URL = today's behavior exactly
Plumbing follows the existing pre-stop/on-complete path: three LaunchConfig
fields → spawn:spot-webhook-url / spawn:webhook-correlation / spawn:webhook-timeout
tags → provider.Config on-node. Also surfaces the instance AZ on-node from the
IMDS identity document (idDoc.AvailabilityZone) for the payload.
Tests: emit payload/echo + no-client_token, opt-in disabled, best-effort drop,
fire-once (pkg/agent); buildTags opt-in tagging (pkg/aws); flag→tag round-trip
e2e (TestTier0_Launch_SpotWebhookTags).
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Closes #228.
What
Adds
spawn launch --spot-webhook-url <url>(+--webhook-correlation,--webhook-timeout). On an AWS spot interruption notice,sporedfires asingle, best-effort
POSTso an off-node consumer (e.g. acohort-stylereconciler) learns about the reclamation inside the ~2-minute window — the
one thing the tag-and-poll surface structurally can't deliver.
This implements the
agent.go:1066// Future enhancement: Support webhooks…note the issue cites, exactly as scoped in the issue + the maintainer/filer
review thread.
Payload (fixed struct + opaque echo)
{ "event": "spot_interruption", "instance_id": "i-0abc…", "region": "us-east-1", "az": "us-east-1a", "action": "terminate", // AWS verbatim: terminate|stop "interruption_deadline": "2026-06-21T18:42:00Z", "name_tag": "mpi-node-0", "compute_seconds": 1234, "last_activity_time": "2026-06-21T18:39:50Z", "correlation": "<echoed verbatim>", "emitted_at": "2026-06-21T18:40:03Z" }Per the review thread — no
client_token. It is not on-node: spored'sconfig comes from
spawn:*tags + IMDS, and theRunInstancesClientToken isneither tagged nor in IMDS. Correlation rides on the opaque
--webhook-correlationblob instead (the consumer already mints its own key), so spawn stays fully
consumer-agnostic. The payload also echoes the AWS
action(terminate vs stop),which the issue's hardcoded
"spot-interruption"reason would have lost.In-grain guarantees (spawn never awaits)
checkSpotInterruptionevery 5s; aguard ensures exactly one POST.
--webhook-timeout(default 2s) hard-caps it so it can't eatthe reclamation window.
can't delay
Cleanup/runPreStop/the survival work (the CRITICAL: spored monitor loop never runs after startup — TTL/idle/on-complete/pre-stop all silently dead #65 discipline).dropped. EC2 state +
spawn:*tags remain the durable source of truth.Plumbing
Follows the existing pre-stop / on-complete path verbatim: three
LaunchConfigfields →
spawn:spot-webhook-url/spawn:webhook-correlation/spawn:webhook-timeouttags (written only when a URL is set) →provider.Configon-node. Also surfaces the instance AZ on-node from the IMDS identity document
(
idDoc.AvailabilityZone) for the payload.Tests
pkg/agent: emit payload + correlation echo + asserts noclient_token;opt-in disabled (no URL → no POST); best-effort drop on 5xx; fire-once.
pkg/aws:buildTagswrites the three tags only when a URL is set.test/e2e:TestTier0_Launch_SpotWebhookTags— flag→tag round-trip against Substrate.make checkgreen; full Tier-0 e2e suite green.