Skip to content

fix(storage): mount EFS by the mount-target IP first, DNS second (#718) - #718

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/718-efs-mount-ip-first
Oct 5, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/718-efs-mount-ip-first

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Follows your question: why bother with EFS DNS at all? Having checked, the answer is mostly "we shouldn't" — #704's ordering was backwards.

What the hardware smoke established

run DNS result
1 failed — all 6 attempts over ~60s
2 failed — all 6 attempts over ~60s
3 succeeded on attempt 1

Intermittent, but when it fails it fails for the whole budget, with a mount target already available in the instance's own subnet and general DNS working. The same mount by IP succeeded first try with identical options.

Why the arguments for the name don't hold here

  • Encryption in transit would genuinely need it — stunnel validates the certificate against fs-….efs.region.amazonaws.com. But spawn has no code path that mounts with TLS: EFSMountOptions.ToMountString emits a fixed set (nfsvers, rsize, wsize, hard, timeo, retrans) and ParseCustomOptions recognises only those keys, so a user cannot pass tls or iam even deliberately.
  • fstab durability across a mount-target replacement is close to worthless for an instance that lives minutes to hours — and had a target really been replaced, the live NFS mount would already be broken; a stale fstab line is the least of it.
  • Free AZ affinity from DNS is real, but spawn already resolves the correct target from the instance's own subnet at launch. Deterministic beats hopeful.

So the name cost a minute of boot in the common failure and bought nothing. It stays as the fallback for when no IP could be resolved — chiefly a caller without elasticfilesystem:DescribeMountTargets — and it is still what goes in /etc/fstab, because the IP is what doesn't survive a replacement.

It also closes the verification gap rather than living with it

This is the part I'd have had to keep apologising for. With DNS first, the IP path ran only when DNS failed — simultaneously load-bearing and never exercised. And because the failure is intermittent, a green smoke could never prove it; I said as much when closing #704.

Inverted, the primary path runs on every launch and every smoke, and the rarely-taken path is the well-understood one. The unprovable thing is now the thing that barely matters.

A 51% cut to the user-data block, incidentally

The rationale above was carried as comments inside the template, so every byte shipped in every instance's 16 KB user-data budget:

rendered EFS block: 3177 bytes  →  1566 bytes

For prose cloud-init never reads. Moved onto GenerateStorageUserData, where it costs nothing. Same lesson as the mpi.go template earlier in this session.

On the tests

The ordering gate compares the offsets of the IP and the DNS name in the rendered script, because a call count cannot distinguish "tried the IP" from "tried it first". Verified to fail against #704's ordering, naming both offsets.

One test previously asserted strings.Contains(script, "mount-target IP") — and broke when I reworded a comment. It now counts mount -t nfs4 invocations (2 with an IP, 1 without), which is immune to comment wording. Worth mentioning because a test that guards generated shell should key on the shell, not the prose around it.

#704's retry is kept intact: the DNS fallback still gets its full six attempts, and a launch with no resolvable IP behaves exactly as it does today.

#704 shipped the obvious order and the hardware smoke showed it was backwards.
Twice out of three runs a mount target already `available` IN THE INSTANCE'S OWN
SUBNET produced "Failed to resolve server" for the entire 60-second retry budget,
while the same mount by IP succeeded first try with identical options.

None of the usual reasons to prefer the name survive contact with spawn:

  - Encryption in transit would need it, because stunnel validates the certificate
    against the DNS name. But spawn has no code path that mounts with TLS:
    EFSMountOptions emits a fixed set and ParseCustomOptions accepts no tls or iam
    key, so a user cannot even ask for it.
  - fstab surviving a mount-target replacement is close to worthless for an
    instance that lives minutes to hours — and had a target really been replaced,
    the live NFS mount would already be broken.
  - DNS resolves to the mount target in the querying instance's AZ for free, but
    spawn already resolves the right target from the instance's own subnet at
    launch. Deterministic beats hopeful.

So the name cost a minute of boot in the common failure and bought nothing. It
stays as the fallback for when no IP could be resolved at all — chiefly a caller
without elasticfilesystem:DescribeMountTargets — and it is still what goes in
/etc/fstab, since the IP does not survive a mount-target replacement.

This also closes a verification gap instead of tolerating it. With DNS first the IP
path ran ONLY when DNS failed, so it was simultaneously load-bearing and never
exercised — and because the failure is intermittent, a passing smoke could not prove
it either way. The primary path now runs on every launch and the rarely-taken path
is the well-understood one.

Separately: the rationale above was carried as comments INSIDE the template, so
every byte shipped in every instance's 16 KB user-data budget. Rendered EFS block
3177 -> 1566 bytes, a 51% cut, for prose cloud-init never reads. Moved onto
GenerateStorageUserData where it costs nothing. Same lesson as the mpi.go template
earlier.

The ordering gate compares the offsets of the IP and the DNS name in the rendered
script, since a call count cannot distinguish "tried the IP" from "tried it first".
Verified to fail against #704's ordering, naming both offsets. One test also now
counts `mount -t nfs4` invocations instead of matching comment prose — the earlier
version broke on a reworded comment, which is exactly the brittleness worth
avoiding in a test that guards generated shell.
@codecov

codecov Bot commented Oct 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit db1708c into main Oct 5, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/718-efs-mount-ip-first branch October 5, 2026 16:36
scttfrdmn added a commit that referenced this pull request Oct 5, 2026
Nine entries: two behaviour changes and seven fixes, three of which were live in
v0.121.0.

Changed:
- EFS mounts by the mount-target IP first, DNS second (#718). #704 shipped the
  obvious order and the hardware smoke disproved it: twice in three runs DNS failed
  for the full 60s budget with the mount target available in the instance's own
  subnet, while the IP mounted first try. Verified on hardware this release — the
  mount source is now 172.31.93.33:/ with no retry lines at all.
- The EFS user-data block is 51% smaller (3177 -> 1566 bytes), because the
  rationale was carried inside the template and shipped in every instance's 16 KB
  budget.

Fixed:
- task status / --wait never read the completion record (#715): the task id was
  appended twice, broken since v0.117.0. Every finished task read as 'running' and
  --wait polled to TTL and exited 1 on tasks that succeeded in seconds.
- #608's stale-record guard had been inert since v0.117.0 for the same reason — the
  pre-launch clear was deleting keys that do not exist, which S3 reports as success.
- spawn orphans and spawn cleanup reported nothing by default (#708): --mine
  filtered on a tag spawn never writes to shared infrastructure, so it emptied the
  result rather than narrowing it. 0 reported in an account holding 27.
- Placement groups were double-reported and the id-keyed copy silently failed to
  delete (#713) — a tolerant error check turned a real failure into success.
- cleanup offered spawn's own shared IAM identity for deletion (#713), unmasked by
  the #708 fix: one bug had been hiding the other.
- The smoke leaked the infrastructure it exists to catch leaks of, and then its new
  leak check reported a false pass over four orphans (#713).

Hardware-verified: make smoke 8/8 on both legs at db1708c. The two
hardware-sensitive paths changed since v0.121.0 are covered — pkg/userdata/
storage.go by the storage leg, and pkg/aws/iam.go's constants-only change by three
successful launches exercising the IAM path.
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.

1 participant