Skip to content

fix(storage): retry the EFS mount, then fall back to the mount-target IP (#704) - #712

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/704-efs-mount-retry
Oct 5, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/704-efs-mount-retry

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #704's retry half. The IP-fallback half stays open — reason at the end.

The bug

pkg/userdata/storage.go issued the mount exactly once. A mount target that was already available in the instance's own subnet still produced:

mount.nfs4: Failed to resolve server fs-0bc771ea6abff6cec.efs.us-east-1.amazonaws.com: Name or service not known

…while general DNS resolved fine and the mount target's IP mounted first try with identical options. EFS DNS can lag mount-target availability.

One blip therefore became a launch that boots, bills and runs nothing — #668's readiness barrier correctly refuses to start a workload against a directory that is not mounted, which is how this was found at all rather than seeing a workload produce garbage.

Six attempts over ~60s now, and nothing added to the common case: the first attempt still mounts and never sleeps, so a retry for an intermittent failure is not paid for by every healthy launch. The final attempt is not followed by a wait nothing uses. fstab keeps the DNS name, not an IP, so the entry survives a mount-target replacement.

The tests execute the shell

This is the part worth reviewing. The bug was invisible to every text assertion, because the mount command was correct — it was simply attempted once. A test that greps the rendered script for mount -t nfs4 passed before and after.

So the tests extract the real spawn_mount_efs out of the generated script and run it under bash with mount, mountpoint and sleep stubbed onto PATH:

  • TestEFSMountRetriesAfterATransientDNSFailure — mount fails twice, succeeds on the third; asserts 3 attempts and that a sleep happened between them.
  • TestEFSMountEventuallyGivesUp — bounded. An unbounded loop would hang the bootstrap, which is worse than a failure the barrier can report and name.
  • TestEFSMountSucceedsFirstTryWithoutWaiting — the happy path gains no delay.
  • The already-mounted shortcut is stubbed to never fire, so it cannot be what makes the retry test pass.

All verified to fail against the single-attempt version; the first names the attempt count.

Why the IP fallback is not here

A persistent DNS failure still fails the mount, and mounting by the mount-target IP would cover that. But spawn does not query mount targets at all today — pkg/aws/efs.go contains exactly one function, GetEFSDNSName, which string-builds the name. So the fallback needs a DescribeMountTargets call plus a new elasticfilesystem:DescribeMountTargets IAM action on the launch role. That is a larger change than the one the issue says would have fixed this launch, so I left it on the issue rather than smuggling it in.

Before tagging

scripts/hardware-smoke-needed.sh flags this, correctly:

⚠️  1 hardware-sensitive area(s) changed. Run 'make smoke' before tagging.
  pkg/userdata/
    changed: pkg/userdata/storage.go

The storage leg (SMOKE_STORAGE=1) is exactly the right check — it creates an EFS filesystem and mount target, launches with --efs-id, and asserts /run/spawn/storage-ready reads ok and /efs is in /proc/mounts. I have not run it, since it launches real instances. Worth doing before this goes out in a release rather than before merge.

One incidental: backticks in the rationale comment terminated the Go raw string — the same trap as the mpi.go template earlier in this session. Prose inside these templates cannot use them.


Correction after running the smoke: the retry alone does not fix this

I ran the storage smoke. The retry is insufficient, and this PR's original claim above — that the retry would have fixed the reported launch — is wrong. The run says so directly:

=== Storage: EFS mount + profile export (1 x t4g.small)
  ✅ launch with --efs-id succeeded
  ❌ storage gate: failed:not mounted: /efs — the mount did not verify
  ❌ /efs is not in /proc/mounts — the mount did not happen
  ✅ profile export resolves to $EFS_MOUNT=/efs (#680)
  --- EFS lines from cloud-init-output.log ---
      | mount.nfs4: Failed to resolve server fs-0cc326d51039a4df6.efs.us-east-1.amazonaws.com
      | spawn: EFS mount attempt 1/6 failed; retrying in 10s
      | mount.nfs4: Failed to resolve server fs-0cc326d51039a4df6.efs.us-east-1.amazonaws.com
      | spawn: EFS mount attempt 2/6 failed; retrying in 10s
      ... (3, 4, 5)
      | spawn: EFS mount failed after 6 attempts over ~60s
      | ❌ prerequisite failed: /run/spawn/storage-ready reports failed:not mounted: /efs

The retry executed exactly as designed — six attempts, 10s apart — and every one failed with the same error. Mount target available in the instance's own subnet, general DNS working, both VPC DNS flags true.

So #704's premise is disconfirmed at 60 seconds. This is not a transient blip a retry rides out: EFS DNS propagation for a freshly created mount target outlasts any retry budget worth spending at boot. The issue's other observation is the one that mattered all along — mount by IP with the same options succeeds, first try.

So the IP fallback is in, and it is the actual fix

EFSMountTargetIP resolves the mount target at launch; the script tries it after the six DNS attempts. The retry stays — the DNS name is the durable reference and deserves its full chance, and a genuinely transient failure is still plausible — but it is no longer load-bearing.

Three deliberate choices:

  • /etc/fstab never carries the IP. A mount-target replacement changes it, which would silently break the next reboot. A test asserts the IP stays out of fstab and the DNS name stays in.
  • Subnet, then AZ, then any available target. Cross-AZ NFS bills per GiB, so exactness is worth preferring — but any available target beats a name that does not resolve, because a workload that cannot see its data costs the whole run.
  • elasticfilesystem:DescribeMountTargets is a new requirement, and nothing in spawn granted EFS actions before (it only string-built the DNS name). A caller without it gets a warning and a DNS-only mount rather than a failed launch. But an API error is surfaced, so a missing grant cannot masquerade as a filesystem with no mount targets.

The new test stubs mount to fail for the DNS name and succeed for the IP — the observed production shape — and asserts all six DNS attempts happen before the fallback. Verified to fail with the fallback removed.

The smoke script was also wrong, in a way worth recording

The first run of this leg produced its fifth false signal, and the first one to draw an actively wrong conclusion rather than an empty one:

  ⚠️  storage gate INCONCLUSIVE: no response over SSM (instance gone?)
  ❌ /efs is not in /proc/mounts — the mount did not happen
  ⚠️  profile export INCONCLUSIVE: no response over SSM

Three different verdicts about one instance in one state. spawn launch returns at state=running, which is minutes before cloud-init installs nfs-utils and mounts — so the leg asserted on a mount that had not been attempted. And every branch treated empty output as no SSM response, making a file that merely did not exist yet indistinguishable from a dead channel.

Fixed in this PR: reachability is established once up front (ssm_wait_online), cloud-init completion is waited for (storage_wait_settled), every probe prints an ABSENT sentinel so absence is a value, and the EFS lines from cloud-init-output.log are dumped whatever the verdict. That last one is what turned the second run into evidence instead of another shrug.

I also avoided a regex escape in that grep — the script's own header records "an escaped grep pattern reaching the instance literally" as a previous false signal, and a \. inside single quotes would have arrived as a literal backslash.

What the run did confirm

The leg still reports 2 failures, which is correct: it ran against the build before the IP fallback. It needs one more run to go green, and I have not spent that yet.


Smoke now green — but it did NOT exercise the fallback, and that corrects me

Re-ran against this branch rebased onto main (so it tests the release candidate, with #706 and #711 in):

=== Storage: EFS mount + profile export (1 x t4g.small)
  ✅ launch with --efs-id succeeded
  ✅ storage gate reported ok (#668)
  ✅ EFS is mounted at /efs
  ✅ profile export resolves to $EFS_MOUNT=/efs (#680)
  --- EFS lines from cloud-init-output.log ---
      | fs-05a3297bb9a1f9428.efs.us-east-1.amazonaws.com:/  8.0E  0  8.0E  0% /efs

=== Result
  8 passed, 0 failed

Read the log rather than the tick marks: there are no EFS mount attempt N/6 failed lines and no mounting by mount-target IP instead line. DNS resolved on the first attempt. So:

Correcting my previous comment

I wrote above that this is "not a transient blip a retry rides out" and that DNS propagation "outlasts any retry budget worth spending at boot." Three runs in, that was over-stated. The actual record:

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

That is intermittent, not deterministic — which partially rehabilitates the original framing in #704. What survives unchanged is the operational point: when it fails, it fails for the entire 60-second budget, so the retry alone is not a reliable fix. Two runs out of three would have left a workload with no data. The fallback is still the right answer; I just can't claim DNS is reliably broken, only that it is unreliable.

A consequence worth noting: because the failure is intermittent, a green smoke is not evidence the fallback works. Only a run that happens to hit the DNS failure would exercise it, and that cannot be scheduled. If you want it proven on hardware, the honest way is a deliberately unresolvable DNS name injected into the template for one run — which I have not done and would want to agree first, since it means shipping a knowingly-broken value to an instance.

No leaks after any of the three runs: independently re-queried for instances, filesystems and smoke security groups — zero each time.

@scttfrdmn scttfrdmn changed the title fix(storage): retry the EFS mount instead of attempting it once (#704) fix(storage): retry the EFS mount, then fall back to the mount-target IP (#704) Oct 5, 2026
A mount target that was already `available` in the instance's OWN subnet still
produced

  mount.nfs4: Failed to resolve server fs-….efs.us-east-1.amazonaws.com

while general DNS resolved fine and the mount target's IP mounted first try. EFS
DNS can lag mount-target availability. The generated script issued the mount
exactly once, so one blip became a launch that boots, bills and runs nothing —
that is not mounted, which is how this was found at all rather than seeing a
workload produce garbage.

Six attempts over ~60s, with nothing added to the common case: the happy path
still mounts on the first try and never sleeps, so a retry for an intermittent
failure is not paid for by every healthy launch. The last attempt is not followed
by a wait nothing uses. fstab keeps the DNS name, not an IP, so the entry survives
a mount-target replacement.

A persistent DNS failure still fails the mount. Falling back to the mount-target
IP would cover that, but spawn does not query mount targets today — only
GetEFSDNSName exists — so it needs a DescribeMountTargets call and a new IAM
action. Left open on #704 rather than smuggled in.

The tests run the REAL generated function under bash with mount/mountpoint/sleep
stubbed on PATH, because this bug was invisible to text assertions: the mount
command was correct and was simply attempted once. They assert the retry engages,
that it is bounded (an unbounded loop hangs the bootstrap, which is worse than a
failure the barrier can report), and that the happy path gains no delay. The
already-mounted shortcut is stubbed to never fire, so it cannot be what makes the
retry test pass. All verified to fail against the single-attempt version.

Also: backticks in the rationale comment terminated the Go raw string — the same
trap as the mpi.go template earlier. Prose inside these templates cannot use them.
…resolve (#704)

The retry committed earlier is not sufficient, and a hardware smoke settled it
rather than leaving it to judgement. On a real t4g.small with the mount target
`available` in its OWN subnet, general DNS working, and enableDnsSupport and
enableDnsHostnames both true:

  mount.nfs4: Failed to resolve server fs-0cc326d51039a4df6.efs.us-east-1.amazonaws.com
  spawn: EFS mount attempt 1/6 failed; retrying in 10s
  ... through 6
  spawn: EFS mount failed after 6 attempts over ~60s
  ❌ prerequisite failed: /run/spawn/storage-ready reports failed:not mounted: /efs

So the retry executed exactly as designed and every attempt failed. #704's own
premise — that this is transient and a retry covers the common case — does not hold
at 60s: EFS DNS propagation for a freshly created mount target outlasts any budget
worth spending at boot. The issue's other observation is the one that matters:
mounting by the mount target's IP succeeds first try with identical options.

So the IP is now resolved at launch and used after the DNS attempts fail. The retry
stays, because the DNS name is the durable reference and deserves its full chance,
and because a genuinely transient failure is still plausible.

/etc/fstab never carries the IP. A mount-target replacement changes it, which would
silently break the next reboot; the IP is strictly a boot-time workaround and a test
asserts it stays out of fstab.

Mount-target selection prefers the instance's own subnet, then its AZ, then any
available target. Cross-AZ NFS bills per GiB, so exactness is worth preferring — but
any available target still beats a name that does not resolve, because a workload
that cannot see its data costs the whole run.

The lookup needs elasticfilesystem:DescribeMountTargets, which nothing in spawn
granted before (it only string-built the DNS name). A caller without it gets a
warning and a DNS-only mount rather than a failed launch — but an API error IS
surfaced, so a missing grant does not masquerade as a filesystem with no mount
targets.

Also fixes the smoke script, which produced its FIFTH false signal on the first run
of this leg — and the first one that drew an actively wrong conclusion rather than an
empty one. It asserted on the mount before cloud-init had attempted it, because
`spawn launch` returns at state=running, and every branch conflated EMPTY OUTPUT
with NO RESPONSE. Now: SSM reachability is established once up front, cloud-init
completion is waited for, every probe prints an ABSENT sentinel so absence is a
value, and the EFS lines from cloud-init-output.log are dumped whatever the verdict
— which is what turned this run into evidence instead of another shrug.
@scttfrdmn
scttfrdmn force-pushed the fix/704-efs-mount-retry branch from ab4e8c9 to 8fb8f64 Compare October 5, 2026 04:44
@scttfrdmn
scttfrdmn merged commit 3504389 into main Oct 5, 2026
6 checks passed
@scttfrdmn
scttfrdmn deleted the fix/704-efs-mount-retry branch October 5, 2026 04:58
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.

EFS mount is attempted once: a transient DNS failure at boot permanently fails the mount, though the mount-target IP works

1 participant