Repository navigation
Merged
Conversation
…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 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.
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 ofprovider.Identity.PublicIP, not by grep. There were three, plus the write-once ready-url and the missing DNS client:spawn:ready-url, no DNS name (DCV and web)refreshReadyURLrewrites 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 stepsRuntimeread the identity snapshotSetPublicIPSource/InstanceIP)ensureDNSClientbuilds it lazily.refreshDNSLeaselooks for an IP at IMDS again once a renewal interval, quietly, and after a resumeThe 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-createdfor 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.golistscmd/spored's deps withgo list -deps -export -json, type-checks every spawn package in that list, and fails on any read ofIdentity.PublicIPoutside 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 exactlynewAgent(agent.go:292),Runtime.buildTemplateContextandPeerRegistry.Register.Tests
pkg/agent/publicip_test.goresumes an instance (1.2.3.4 -> 5.6.7.8) throughcheckAndActfor each consumer. Every test was watched failing against a revert that compiles:refreshReadyURLcall, or make it a no-op: the DCV and web ready-url tests fail (URL still at 1.2.3.4)InstanceIPignores the source, orattachPluginRuntimedoesn't set it: the{{ instance.ip }}tests failrefreshDNSLease'sdnsClient == nilearly return: both DNS subtests fail. Drop the IMDS re-look: the "found by the renewal" subtest failsPeerRegistry.ipignores the source, orattachRegistrydoesn't set it: the registry test fails (Substrate emulator, in-process)make check: everything passes except the known Docker-onlyTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.make check-nested: all 9 nested modules clean.go test -raceon agent, pluginruntime and registry: clean.Caveats
newAgentcall toattachRegistrysits behind the real-AWS activate path, so no test goes through it.attachRegistryitself is tested.remote.starton resume is not part of this PR.