Skip to content

Register only hybrid job-array members with the hybrid registry (#904) - #920

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/904
Oct 15, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/904

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Problem

spored set up the hybrid registry (registry.NewPeerRegistry, Register, StartHeartbeat, and Deregister on cleanup) for any instance with spawn:job-array-id. buildJobArrayMemberConfig puts that tag on every spawn launch --count member, MPI or not. Nothing reads the registry for those arrays: EC2Provider.DiscoverPeers uses tags, and MPI peers come from the cohort Assembler. Registration also failed on every one of them, because spored-instance-role has no DynamoDB grant and the table only exists where spawn burst has run. The result was a warning on every boot, plus heartbeat noise. Once #902 gives the client a region, those failures become AccessDenied or ResourceNotFound instead of Missing Region.

What identifies a hybrid member

  • The local provider. LocalProvider.DiscoverPeers is the only production reader of the registry, so a local node has to register for the other local nodes to find it.
  • spawn:burst=true. Only spawn burst writes this tag (cmd/burst.go). It is also the only path that creates the table (registry.EnsureTable), and it sets spawn:job-array-id too. Burst members have to register so the local nodes can see them.

Nothing else in the repo sets spawn:burst. pkg/aws.buildTags (used by spawn launch) never does.

Fix

  • provider.Config.Burst is a new field, parsed from spawn:burst (via tagprefix.Tag("burst")) in loadConfigFromEC2Tags.
  • joinsHybridRegistry(identity, config) in pkg/agent is true only for a job-array member that is either Provider == "local" or Config.Burst. It gates the registry block in newAgent. Ordinary members log Hybrid registry skipped: … instead of a failure.
  • Peer discovery is unchanged. prov.DiscoverPeers still runs for every job-array member. It is now its own block right after the registry one.
  • Deregister was already gated on a.registry != nil, so it follows the new gate automatically.
  • newPeerRegistry is a package var so tests can watch whether activation reaches it without touching DynamoDB.

This does not overlap #902's region change (pkg/registry, pkg/provider/local.go, Identity.AWSRegion). In agent.go only the registry/discovery block changes. The CHANGELOG ### Fixed entry under [Unreleased] will likely need a trivial conflict resolution with #902.

Tests

  • pkg/agent/hybrid_registry_test.go
    • TestJoinsHybridRegistry tests the predicate directly (rule 2): an ordinary EC2 member is out, a burst member is in, a local node is in, no array means out, and nil inputs are out.
    • TestNewAgent_RegistersOnlyHybridMembersWithTheRegistry goes through the daemon's NewAgent. The registry is built for burst and local members and not for an ordinary member. DiscoverPeers still runs for all three.
  • pkg/provider/burst_tag_test.go: spawn:burst=true sets Config.Burst; false or a missing tag doesn't (run against Substrate).
  • cmd/burst_tags_test.go: every instance launchBurstInstances launches carries exactly the key spored reads (tagprefix.Tag("burst")) set to true, plus the job-array id (run against Substrate).
  • pkg/aws/tags_test.go TestBuildTags_JobArrayMemberIsNotTaggedBurst: a spawn launch job-array member gets spawn:job-array-id but never spawn:burst.

Each test was watched failing against a revert that compiles, with go vet clean on each reverted tree:

Revert Fails
predicate → true || … both agent tests
gate → the old config.JobArrayID != "" the NewAgent ordinary-member case
tag parse → false && … TestLoadConfigFromEC2Tags_Burst
burst tag key → spawn:burst-x TestLaunchBurstInstances_TagsMembersAsBurst
buildTags emits spawn:burst for arrays TestBuildTags_JobArrayMemberIsNotTaggedBurst

make check passes except TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, which needs a Docker daemon that wasn't available locally. All 9 nested modules pass, and so does the public-surface snapshot (no exported change in a public package). No AWS resources were created.

Related, filed separately

Fixes #904

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

scttfrdmn added a commit that referenced this pull request Oct 15, 2026
TestNewAgent_StillActivates called the real NewAgent, which built a real DNS
client, DynamoDB registry and EC2 tag writer from ambient credentials: every
`make check` with a profile set did a real Route53 UPSERT via the DNS API, an
EC2 CreateTags and a DynamoDB PutItem, and passed either way.

- pkg/agent: newDNSClient/newPeerRegistry/newTagPutter seams (newPeerRegistry
  named as in #920); the activation test now asserts the leased UPSERT, the
  dns-status tag and the registry PutItem through httptest fakes. An
  fsxMounter seam keeps the FSx gating test off DescribeFileSystems.
- Other offenders found by running every module under the new gate: provider
  and config public-IP lookups (ipify/ifconfig.me/icanhazip), taskpool job
  scripts' `aws s3 cp` (stub aws on PATH), ttl-reaper's init-time STS
  GetCallerIdentity (moved to main), a dashboard-api handler test's DynamoDB
  GetItem (loadAWSConfig seam), dns-updater handler tests' registry Scan.
- Gate: internal/hermetic + test/hermetic, a `go test -exec` wrapper that
  strips AWS_* and sets fake creds, points AWS_ENDPOINT_URL and HTTP(S)_PROXY
  at a loopback recorder, and fails the package naming every request. The
  proxy is what catches the DNS client, which is not an SDK client. Wired into
  make check, CI (test, race, API surface) and scripts/nested-modules.sh;
  pkg/agent also installs it via TestMain. TestGateIsWired checks the wiring.

(#968)
scttfrdmn added a commit that referenced this pull request Oct 15, 2026
TestNewAgent_StillActivates called the real NewAgent, which built a real DNS
client, DynamoDB registry and EC2 tag writer from ambient credentials: every
`make check` with a profile set did a real Route53 UPSERT via the DNS API, an
EC2 CreateTags and a DynamoDB PutItem, and passed either way.

- pkg/agent: newDNSClient/newPeerRegistry/newTagPutter seams (newPeerRegistry
  named as in #920); the activation test now asserts the leased UPSERT, the
  dns-status tag and the registry PutItem through httptest fakes. An
  fsxMounter seam keeps the FSx gating test off DescribeFileSystems.
- Other offenders found by running every module under the new gate: provider
  and config public-IP lookups (ipify/ifconfig.me/icanhazip), taskpool job
  scripts' `aws s3 cp` (stub aws on PATH), ttl-reaper's init-time STS
  GetCallerIdentity (moved to main), a dashboard-api handler test's DynamoDB
  GetItem (loadAWSConfig seam), dns-updater handler tests' registry Scan.
- Gate: internal/hermetic + test/hermetic, a `go test -exec` wrapper that
  strips AWS_* and sets fake creds, points AWS_ENDPOINT_URL and HTTP(S)_PROXY
  at a loopback recorder, and fails the package naming every request. The
  proxy is what catches the DNS client, which is not an SDK client. Wired into
  make check, CI (test, race, API surface) and scripts/nested-modules.sh;
  pkg/agent also installs it via TestMain. TestGateIsWired checks the wiring.

(#968)
scttfrdmn added a commit that referenced this pull request Oct 15, 2026
TestNewAgent_StillActivates called the real NewAgent, which built a real DNS
client, DynamoDB registry and EC2 tag writer from ambient credentials: every
`make check` with a profile set did a real Route53 UPSERT via the DNS API, an
EC2 CreateTags and a DynamoDB PutItem, and passed either way.

- pkg/agent: newDNSClient/newPeerRegistry/newTagPutter seams (newPeerRegistry
  named as in #920); the activation test now asserts the leased UPSERT, the
  dns-status tag and the registry PutItem through httptest fakes. An
  fsxMounter seam keeps the FSx gating test off DescribeFileSystems.
- Other offenders found by running every module under the new gate: provider
  and config public-IP lookups (ipify/ifconfig.me/icanhazip), taskpool job
  scripts' `aws s3 cp` (stub aws on PATH), ttl-reaper's init-time STS
  GetCallerIdentity (moved to main), a dashboard-api handler test's DynamoDB
  GetItem (loadAWSConfig seam), dns-updater handler tests' registry Scan.
- Gate: internal/hermetic + test/hermetic, a `go test -exec` wrapper that
  strips AWS_* and sets fake creds, points AWS_ENDPOINT_URL and HTTP(S)_PROXY
  at a loopback recorder, and fails the package naming every request. The
  proxy is what catches the DNS client, which is not an SDK client. Wired into
  make check, CI (test, race, API surface) and scripts/nested-modules.sh;
  pkg/agent also installs it via TestMain. TestGateIsWired checks the wiring.

(#968)
spored registered every instance carrying spawn:job-array-id, which every
spawn launch --count/--mpi member carries. Nothing reads the registry for those
arrays, and registration failed on all of them (no DynamoDB grant on the
instance role; the table exists only where spawn burst ran). Now only a local
node or an instance tagged spawn:burst=true by spawn burst registers. Peer
discovery is unchanged.
scttfrdmn added a commit that referenced this pull request Oct 15, 2026
TestNewAgent_StillActivates called the real NewAgent, which built a real DNS
client, DynamoDB registry and EC2 tag writer from ambient credentials: every
`make check` with a profile set did a real Route53 UPSERT via the DNS API, an
EC2 CreateTags and a DynamoDB PutItem, and passed either way.

- pkg/agent: newDNSClient/newPeerRegistry/newTagPutter seams (newPeerRegistry
  named as in #920); the activation test now asserts the leased UPSERT, the
  dns-status tag and the registry PutItem through httptest fakes. An
  fsxMounter seam keeps the FSx gating test off DescribeFileSystems.
- Other offenders found by running every module under the new gate: provider
  and config public-IP lookups (ipify/ifconfig.me/icanhazip), taskpool job
  scripts' `aws s3 cp` (stub aws on PATH), ttl-reaper's init-time STS
  GetCallerIdentity (moved to main), a dashboard-api handler test's DynamoDB
  GetItem (loadAWSConfig seam), dns-updater handler tests' registry Scan.
- Gate: internal/hermetic + test/hermetic, a `go test -exec` wrapper that
  strips AWS_* and sets fake creds, points AWS_ENDPOINT_URL and HTTP(S)_PROXY
  at a loopback recorder, and fails the package naming every request. The
  proxy is what catches the DNS client, which is not an SDK client. Wired into
  make check, CI (test, race, API surface) and scripts/nested-modules.sh;
  pkg/agent also installs it via TestMain. TestGateIsWired checks the wiring.

(#968)
@scttfrdmn
scttfrdmn merged commit de494b3 into main Oct 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/904 branch October 15, 2026 19:53
scttfrdmn added a commit that referenced this pull request Oct 15, 2026
TestNewAgent_StillActivates called the real NewAgent, which built a real DNS
client, DynamoDB registry and EC2 tag writer from ambient credentials: every
`make check` with a profile set did a real Route53 UPSERT via the DNS API, an
EC2 CreateTags and a DynamoDB PutItem, and passed either way.

- pkg/agent: newDNSClient/newPeerRegistry/newTagPutter seams (newPeerRegistry
  named as in #920); the activation test now asserts the leased UPSERT, the
  dns-status tag and the registry PutItem through httptest fakes. An
  fsxMounter seam keeps the FSx gating test off DescribeFileSystems.
- Other offenders found by running every module under the new gate: provider
  and config public-IP lookups (ipify/ifconfig.me/icanhazip), taskpool job
  scripts' `aws s3 cp` (stub aws on PATH), ttl-reaper's init-time STS
  GetCallerIdentity (moved to main), a dashboard-api handler test's DynamoDB
  GetItem (loadAWSConfig seam), dns-updater handler tests' registry Scan.
- Gate: internal/hermetic + test/hermetic, a `go test -exec` wrapper that
  strips AWS_* and sets fake creds, points AWS_ENDPOINT_URL and HTTP(S)_PROXY
  at a loopback recorder, and fails the package naming every request. The
  proxy is what catches the DNS client, which is not an SDK client. Wired into
  make check, CI (test, race, API surface) and scripts/nested-modules.sh;
  pkg/agent also installs it via TestMain. TestGateIsWired checks the wiring.

(#968)
scttfrdmn added a commit that referenced this pull request Oct 15, 2026
#1003)

* Make unit tests hermetic: no real AWS/DNS calls from make check (#968)

TestNewAgent_StillActivates called the real NewAgent, which built a real DNS
client, DynamoDB registry and EC2 tag writer from ambient credentials: every
`make check` with a profile set did a real Route53 UPSERT via the DNS API, an
EC2 CreateTags and a DynamoDB PutItem, and passed either way.

- pkg/agent: newDNSClient/newPeerRegistry/newTagPutter seams (newPeerRegistry
  named as in #920); the activation test now asserts the leased UPSERT, the
  dns-status tag and the registry PutItem through httptest fakes. An
  fsxMounter seam keeps the FSx gating test off DescribeFileSystems.
- Other offenders found by running every module under the new gate: provider
  and config public-IP lookups (ipify/ifconfig.me/icanhazip), taskpool job
  scripts' `aws s3 cp` (stub aws on PATH), ttl-reaper's init-time STS
  GetCallerIdentity (moved to main), a dashboard-api handler test's DynamoDB
  GetItem (loadAWSConfig seam), dns-updater handler tests' registry Scan.
- Gate: internal/hermetic + test/hermetic, a `go test -exec` wrapper that
  strips AWS_* and sets fake creds, points AWS_ENDPOINT_URL and HTTP(S)_PROXY
  at a loopback recorder, and fails the package naming every request. The
  proxy is what catches the DNS client, which is not an SDK client. Wired into
  make check, CI (test, race, API surface) and scripts/nested-modules.sh;
  pkg/agent also installs it via TestMain. TestGateIsWired checks the wiring.

(#968)

* Consolidate CHANGELOG groups after rebase

* Make the activation test's member a burst member now that only hybrid members register (#904, #968)
scttfrdmn added a commit that referenced this pull request Oct 15, 2026
…ent.Launch, and TestBurstMembersAreTaggedBurst covers the same assertion (#905)
scttfrdmn added a commit that referenced this pull request Oct 15, 2026
* Give spawn burst instances credentials, tags and a TTL (#905)

spawn burst launched its members with no IAM instance profile, five
hand-written tags, no TTL and unencoded user-data. RunInstances rejected the
user-data, so every burst failed. Had it not, the members would have had no
credentials for spored, no spawn:managed tag (so the TTL reaper, spawn list and
the spored role's terminate grant could not reach them), no deadline, and the
same job-array index on every member.

Burst now resolves the instance profile the way spawn launch does with no
--iam-* flags (SetupSporedIAMRole, or --instance-profile to skip it). It
launches each member through pkg/aws Client.Launch, so buildTags writes the
same tags a spawn launch job-array member gets, with a per-member index and a
TTL (--ttl, default 8h; must parse as a Go duration so the deadline is
computed). spawn:burst=true is added as a burst-only custom tag, never by
buildTags (#904). --job-array-name defaults to the ID so the printed spawn
array status hint finds the members.

Both spored policies now grant PutItem/UpdateItem/DeleteItem/Query on
spawn-hybrid-registry in the caller's own account, which is what the
in-instance registry client calls. Without that, no job-array member could
register.

Fixes #917.

* Drop #920's burst tag test: launchBurstInstances now goes through Client.Launch, and TestBurstMembersAreTaggedBurst covers the same assertion (#905)
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…ry (#918)

The hybrid registry is written by local nodes and burst members alike, but
only LocalProvider read it. EC2Provider.DiscoverPeers looked at tags only, so
a burst instance saw its EC2 siblings and never the local nodes of its job
array: discovery worked one way.

A burst member (spawn:burst=true, parsed into Config.Burst exactly as #920
does) now also queries the registry and merges its entries with the tag
peers, one entry per instance, the tag entry winning a collision since it
carries the spore.host DNS name. A registry read failure keeps the tag peers
and logs a warning. Ordinary members stay tag-only and never query the table.

The registry query and its parsing move into pkg/provider/hybrid_registry.go,
shared with the local provider (which also gains pagination). The table name
is pinned to registry.TableName by a test, and the spored IAM grant gate now
discovers the DynamoDB calls this reader makes as well as PeerRegistry's.

Fixes #918.
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…ry (#918)

The hybrid registry is written by local nodes and burst members alike, but
only LocalProvider read it. EC2Provider.DiscoverPeers looked at tags only, so
a burst instance saw its EC2 siblings and never the local nodes of its job
array: discovery worked one way.

A burst member (spawn:burst=true, parsed into Config.Burst exactly as #920
does) now also queries the registry and merges its entries with the tag
peers, one entry per instance, the tag entry winning a collision since it
carries the spore.host DNS name. A registry read failure keeps the tag peers
and logs a warning. Ordinary members stay tag-only and never query the table.

The registry query and its parsing move into pkg/provider/hybrid_registry.go,
shared with the local provider (which also gains pagination). The table name
is pinned to registry.TableName by a test, and the spored IAM grant gate now
discovers the DynamoDB calls this reader makes as well as PeerRegistry's.

Fixes #918.
scttfrdmn added a commit that referenced this pull request Oct 17, 2026
…ry (#918) (#934)

The hybrid registry is written by local nodes and burst members alike, but
only LocalProvider read it. EC2Provider.DiscoverPeers looked at tags only, so
a burst instance saw its EC2 siblings and never the local nodes of its job
array: discovery worked one way.

A burst member (spawn:burst=true, parsed into Config.Burst exactly as #920
does) now also queries the registry and merges its entries with the tag
peers, one entry per instance, the tag entry winning a collision since it
carries the spore.host DNS name. A registry read failure keeps the tag peers
and logs a warning. Ordinary members stay tag-only and never query the table.

The registry query and its parsing move into pkg/provider/hybrid_registry.go,
shared with the local provider (which also gains pagination). The table name
is pinned to registry.TableName by a test, and the spored IAM grant gate now
discovers the DynamoDB calls this reader makes as well as PeerRegistry's.

Fixes #918.
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.

spored registers every job-array member with the hybrid registry, which only hybrid/burst arrays use

1 participant