feat(agent): client helper + cache cloud-init install (FJB-94 Phase C)#113
Open
hstern wants to merge 1 commit into
Open
feat(agent): client helper + cache cloud-init install (FJB-94 Phase C)#113hstern wants to merge 1 commit into
hstern wants to merge 1 commit into
Conversation
Third slice of FJB-94. Lands the orchestrator-side dial — generic
agent.NewClient producing an AgentServiceClient given a DialContext,
addr, and bearer token — plus the cache cloud-init extension that
installs fjbagent on the cache nanode the same way Phase B installed
it on workers. Together with Phase A/B, this completes the FJB-94
foundation.
agent.NewClient:
- DialContextFunc abstraction lets the orchestrator pass
wg.Tunnel.DialContext in production, net.Dialer.DialContext in
tests.
- HTTP/2 cleartext via http2.Transport.AllowHTTP + DialTLSContext
returning a plain TCP conn. Matches agent server-side h2c.
- Bearer interceptor sets Authorization on both unary and
streaming RPCs (FJB-93's Exec needs the streaming path).
Cache deploy:
- cacheCloudInitParams gains FJBAgentDownloadURL + FJBAgentToken +
FJBAgentServiceUnit + FJBAgentListenPort; ServiceUnit comes from
bootstrap.FJBAgentServiceUnit() so worker and cache share one
systemd unit file.
- cache-cloud-init.yaml.tmpl mirrors the worker install block:
same fjb system user, same auth.token mode 0600, same
/etc/default/fjbagent env file, same systemd Type=notify unit,
same curl-then-enable-service runcmd. Gated on
FJBAgentDownloadURL non-empty.
- Linode.SetFJBAgent is the duck-typed wiring main.go uses
(matching SetTransportMode / SetACLSource shape); empty pair
disables the install for the cache the same way it does for
workers.
main.go:
- buildOrchestratorConfig pushes the resolved knobs into the
provider via duck typing inline (skip the docker provider, no-op
when cache isn't configured). Locality > separate helper here
since the call site is small.
Tests: 5 new agent.NewClient cases over h2c (Health no-auth + with
token + wrong-token rejected, Exec streaming with bearer, sentinel
DialContext is actually used), 3 new cache renderer cases. Full
go test -race ./... clean. golangci-lint clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
14f41b9 to
8c4c79b
Compare
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
Third (final) slice of FJB-94. Lands the orchestrator-side dial + cache deploy. Together with Phases A/B, the agent foundation is complete: agent installed on workers + cache, orchestrator has the wire shape to dial both.
Builds on: PR #111 (Phase B). PR diff shows Phase B's commits too until Phase B merges to main, at which point this rebases clean and the diff narrows to Phase C only.
What's in
internal/agent/client.go—NewClient(ClientOptions{Addr, Token, DialContext})returning anAgentServiceClient. h2c viahttp2.Transport.AllowHTTP+DialTLSContext. Bearer interceptor wraps unary AND streaming RPCs (FJB-93'sExecis bidi).cacheCloudInitParamsgains the agent triplet;bootstrap.FJBAgentServiceUnit()is the canonical unit shared with worker installs.Linode.SetFJBAgentis the duck-typed wiring main.go uses.internal/provider/linode/cache-cloud-init.yaml.tmpl— same install block as workers, gated onFJBAgentDownloadURL.cmd/fj-bellows/main.go—buildOrchestratorConfigpushes the knobs into the provider via duck-typedSetFJBAgentso the managed cache renders the same install.Test plan
agent.NewClientcases over h2c.go test -race ./...clean.golangci-lintclean.🤖 Generated with Claude Code