Repository navigation
fix(storage): retry the EFS mount, then fall back to the mount-target IP (#704) - #712
Merged
Merged
Conversation
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
force-pushed
the
fix/704-efs-mount-retry
branch
from
October 5, 2026 04:44
ab4e8c9 to
8fb8f64
Compare
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.
Closes #704's retry half. The IP-fallback half stays open — reason at the end.
The bug
pkg/userdata/storage.goissued the mount exactly once. A mount target that was alreadyavailablein the instance's own subnet still produced:…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.
fstabkeeps 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 nfs4passed before and after.So the tests extract the real
spawn_mount_efsout of the generated script and run it under bash withmount,mountpointandsleepstubbed 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.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.gocontains exactly one function,GetEFSDNSName, which string-builds the name. So the fallback needs aDescribeMountTargetscall plus a newelasticfilesystem:DescribeMountTargetsIAM 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.shflags this, correctly: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-readyreadsokand/efsis 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.gotemplate 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:
The retry executed exactly as designed — six attempts, 10s apart — and every one failed with the same error. Mount target
availablein 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
EFSMountTargetIPresolves 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/fstabnever 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.elasticfilesystem:DescribeMountTargetsis 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
mountto 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:
Three different verdicts about one instance in one state.
spawn launchreturns atstate=running, which is minutes before cloud-init installsnfs-utilsand 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 anABSENTsentinel so absence is a value, and the EFS lines fromcloud-init-output.logare 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
$EFS_MOUNT=/efsafter sourcing the generated profile — the quoting fix this smoke leg was built for.failed:not mounted: /efs, and the command refused to start rather than running against a missing directory.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):
Read the log rather than the tick marks: there are no
EFS mount attempt N/6 failedlines and nomounting by mount-target IP insteadline. DNS resolved on the first attempt. So:mountfailing for the name and succeeding for the IP) and not yet by a real instance.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:
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.