feat(linode): orchestrator-side cache wg-pubkey discovery — Phase B (FJB-99)#112
Merged
Merged
Conversation
…FJB-99)
Completes the bootstrap loop FJB-99 Phase A started: the cache nanode
generates its WG keypair at first boot and publishes the pubkey to S3
as public-read; the orchestrator polls the bucket via plain HTTPS GET
(no S3 SDK — WG public keys are designed to be world-readable) and
reads the cache's public IPv4 from the Linode API to build the WG
peer endpoint. Both feed into wgboot.Config as runtime overrides for
transport.wg.peer.{public_key,endpoint}.
Why HTTPS GET over signed S3: WG pubkeys are intentionally public;
the threat model isn't worse than what's already on the wire during
a handshake. Skipping the S3 SDK keeps the dependency surface lean.
What lands:
- cache cloud-init: the aws s3 cp now sets --acl public-read so the
orchestrator can fetch the pubkey via plain HTTPS.
- managedCache.WaitForWGPubkey: polls <bucket-endpoint>/<bucket>/wg-
pubkey.txt with 5s initial delay, exponential backoff to 30s, ctx-
cancellable. Returns the trimmed pubkey on first 200 OK with a
non-empty body.
- managedCache.PublicEndpoint: GetInstance on the cache linodeID,
picks the public (non-RFC1918) IPv4, appends the operator-configured
listen port or defaults to 51820.
- Linode duck-typed accessors WaitForCacheWGPubkey + CachePublic-
Endpoint surface both through cmd/fj-bellows.
- wgboot.Config: new optional CachePubkey + CacheEndpoint fields.
planBoot reads from override first, falls back to config peer
knobs, errors out at boot if neither is set — clear error message
points operators at the bootstrap loop.
- config.WGPeer.validate: public_key + endpoint are now optional at
config-load time (the bootstrap loop populates them at runtime).
- cmd/fj-bellows.discoverCachePeer: runs the bootstrap loop ONLY when
static config knobs are empty. Daemon startup stays fast under
back-compat static config — matters for the FJB-91 e2e harness
that uses the persistent test cache.
Tests cover the bucket-poll happy path, timeout surface, public-IPv4
selection, and wgboot's new no-peer rejection. Verified end-to-end
against live Linode via test/e2e-linode/run-local.sh --transport=
cache-gateway (FJB-91 stack-up scope still passes; the new code path
is exercised but no-op since the harness sets static peer config).
Out of scope (FJB-99 Phase C):
- e2e harness reactivation against the ephemeral cache (drops
persistent-cache preflight, reactivates worker readiness checks).
- Drop the static transport.wg.peer.{public_key,endpoint} config
knobs entirely.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Completes the FJB-99 bootstrap loop started in Phase A. The cache publishes its WG pubkey to S3 as public-read; the orchestrator polls via plain HTTPS GET (no S3 SDK — WG pubkeys are designed to be world-readable), reads the cache's public IPv4 from the Linode API, and feeds both into
wgboot.Configas runtime overrides fortransport.wg.peer.{public_key,endpoint}.aws s3 cpnow sets--acl public-read.<bucket-endpoint>/<bucket>/wg-pubkey.txtwith 5s → 30s exponential backoff. Returns the trimmed pubkey on first 200 OK.GetInstance(linodeID), picks the public (non-RFC1918) IPv4, appends operator-configured listen port (or 51820).Linode.{WaitForCacheWGPubkey,CachePublicEndpoint}: duck-typed accessors for cmd/fj-bellows.CachePubkey+CacheEndpointoverrides.planBootreads override first, falls back to config peer, errors with a clear message pointing at the bootstrap loop if neither is set.public_key+endpointare now optional at config-load (the loop fills them at runtime).Why HTTPS GET, not signed S3
WG public keys are intentionally public; the threat model isn't worse than what's already on the wire during a handshake. Skipping the S3 SDK keeps the dep surface lean.
Not in this PR (Phase C)
transport.wg.peer.{public_key,endpoint}config knobs entirely.Test plan
go build ./...go test ./...(incl.TestWaitForWGPubkey_*,TestPublicEndpoint_PicksPublicIPv4,TestBoot_RejectsMissingPeerWithoutOverrides)golangci-lint run(0 issues)bash test/e2e-linode/run-local.sh --transport=cache-gateway→ ALL OK (live Linode; static-peer back-compat path verified — Phase C exercises the dynamic bootstrap path)🤖 Generated with Claude Code