Skip to content

Route every spored use of the public IP through the value a resume refreshes (#1019) - #1033

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/1019
Oct 17, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/1019

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1019

Stacked on #1020 (fix/987). Merge that first; this PR's base is fix/987.

What was still using the boot-time IP

#1020 re-reads the public IP after a resume into a guarded value (Agent.publicIP). I found the other readers by type-checking spored's whole import graph for reads of provider.Identity.PublicIP, not by grep. There were three, plus the write-once ready-url and the missing DNS client:

consumer before now
spawn:ready-url, no DNS name (DCV and web) written once with the boot IP refreshReadyURL rewrites the URL tag on the tick after the IP changes. It keeps the same token and session and retries a failed write
{{ instance.ip }} in plugin steps Runtime read the identity snapshot reads the agent's current value (SetPublicIPSource / InstanceIP)
hybrid registry entry re-registered on resume identity snapshot same kind of source
DNS when the first boot had no public IP no client was ever built ensureDNSClient builds it lazily. refreshDNSLease looks for an IP at IMDS again once a renewal interval, quietly, and after a resume

The ready-url handshake is not re-run. Its give-up deadlines count from spored's start, so re-running it after a resume could record a terminal web-not-responding / session-never-created for an app that is only slow to come back. Only the URL is rewritten. The DCV token stays valid for the session's lifetime, so the rewritten URL uses the same token.

Gate

spored_public_ip_test.go lists cmd/spored's deps with go list -deps -export -json, type-checks every spawn package in that list, and fails on any read of Identity.PublicIP outside the three fallback getters. It also fails if discovery finds no packages, or if it does not see a fallback getter (in which case the gate is blind). Against the pre-fix code it reports exactly newAgent (agent.go:292), Runtime.buildTemplateContext and PeerRegistry.Register.

Tests

pkg/agent/publicip_test.go resumes an instance (1.2.3.4 -> 5.6.7.8) through checkAndAct for each consumer. Every test was watched failing against a revert that compiles:

  • drop the refreshReadyURL call, or make it a no-op: the DCV and web ready-url tests fail (URL still at 1.2.3.4)
  • InstanceIP ignores the source, or attachPluginRuntime doesn't set it: the {{ instance.ip }} tests fail
  • restore refreshDNSLease's dnsClient == nil early return: both DNS subtests fail. Drop the IMDS re-look: the "found by the renewal" subtest fails
  • PeerRegistry.ip ignores the source, or attachRegistry doesn't set it: the registry test fails (Substrate emulator, in-process)

make check: everything passes except the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested: all 9 nested modules clean. go test -race on agent, pluginruntime and registry: clean.

Caveats

  • Not reproduced on a real hibernated instance. No AWS resources were used.
  • The newAgent call to attachRegistry sits behind the real-AWS activate path, so no test goes through it. attachRegistry itself is tested.
  • A plugin that baked the IP into a file at install time (a config file written by a start step) keeps the old one; only steps run after the resume see the new IP. Re-running remote.start on resume is not part of this PR.
  • An EIP associated later to an instance that already had a public IP is still not noticed until a resume. Only an instance with no IP keeps looking.

…freshes (#1019)

field (Agent.publicIP) and re-registers DNS with it. Three other users of
the IP still had the one from the first boot, and one never got a chance:

- spawn:ready-url on an instance with no DNS name. The DCV and web
  handshakes write it once. The handshake now records the host it used
  and how to build the URL for another host (same token, same session).
  refreshReadyURL rewrites only the URL tag when the host changes, every
  tick, retrying a failed write. It does not re-run the handshake: the
  handshake's give-up deadlines count from spored's start and would
  record a terminal failure for an app that is slow to come back.
- {{ instance.ip }}. pluginruntime.Runtime read the boot-time identity.
  It now reads a source the agent sets (SetPublicIPSource, through
  attachPluginRuntime), exposed as Runtime.InstanceIP.
- The hybrid registry entry re-registered on resume. PeerRegistry gets
  the same kind of source (attachRegistry).
- The DNS client existed only if the first boot had a public IP.
  ensureDNSClient now builds it lazily, from the boot path and from
  refreshDNSLease. An instance without an IP looks again at IMDS once a
  renewal interval (quietly: a 404 is the normal answer in a private
  subnet), and a resume re-reads it too.

The consumers were found by type, not by grep, and a gate now keeps it
that way: spored_public_ip_test.go type-checks every spawn package in
cmd/spored's import graph (from `go list -deps -export`) and fails on any
read of provider.Identity.PublicIP outside the three fallback getters.
Against the pre-fix code it reports exactly newAgent, buildTemplateContext
and PeerRegistry.Register.

Tests in pkg/agent/publicip_test.go drive a resume through checkAndAct
for each consumer. Each fails against a compiling revert of its fix.
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

@scttfrdmn
scttfrdmn merged commit 2a494b3 into main Oct 17, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1019 branch October 17, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

After a resume with a new public IP, ready-url (no DNS name) and plugin {{ instance.ip }} still carry the old IP

1 participant