Repository navigation
Conversation
The sandbox asset and OCI bundle prep reads only the request, so Restore now starts it before fetching the snapshot manifest. Only the snapshot download needs the manifest. A manifest failure cancels the prep and waits for it before returning. A failed restore can leave a detached asset fetch running, so the tests that fail on the manifest join it before cleanup.
Sunny (sunnylovestiramisu)
left a comment
There was a problem hiding this comment.
Just leaving some questions.
| if sandboxRec, err = unmarshalSandboxRecord(manifest); err != nil { | ||
| return nil, fmt.Errorf("while unmarshalling sandbox record: %w", err) | ||
| dManifest = time.Since(tManifest) | ||
| stopPrep() |
There was a problem hiding this comment.
On a manifest failure, stopPrep unblocks the caller, but filecache runs the flight on WithoutCancel, so the asset download keeps going after Restore returns. Is that intended? Have you considered starting prep only after readLocalSnapshot succeeds, or in parallel with just the remote fetch, so a never-uploaded snapshot doesn't kick off node work? If it's fine as is, maybe drop 'waits for it' from the description.
There was a problem hiding this comment.
Intended. The flights are shared and detached so they warm the cache for the next caller. The same already happens when the snapshot download fails. A never-uploaded snapshot fails on the remote fetch, so starting prep after readLocalSnapshot or alongside only the remote fetch still starts it. Only waiting for the manifest avoids it, and that undoes the change. The leftover work is one deduplicated asset fetch and one image pull under pullTimeout. I fixed the wording in the commit message, the stopPrep comment and the description.
| Spec: &ateletpb.WorkloadSpec{}, | ||
| Snapshot: lifecycleSnapshot(actorUID, snapshotName, 1, ateletpb.SnapshotFidelity_SNAPSHOT_FIDELITY_MEMORY), | ||
| }) | ||
| waitAssetFetch(t, s, rec) |
There was a problem hiding this comment.
Could we get a test where the manifest fetch blocks or fails while prep is in flight? Right now nothing checks that the overlap actually happens or that stopPrep cancels the unpack.
There was a problem hiding this comment.
Added TestRestoreManifestFailureStopsPrep. The manifest fetch answers NotFound only once the asset fetch has started, and the asset fetch blocks until the test releases it. Restore must return while it is still blocked. Without the overlap the manifest fetch never answers and the test times out.
| // stopPrep cancels the prep leg after a manifest failure and waits for it, | ||
| // so its phases are reported as cut short. | ||
| stopPrep := func() { | ||
| cancelPrep() | ||
| if gErr := g.Wait(); gErr != nil { | ||
| dAssets, dBundles = assetsAfterCollateral(prepFailedPhase, dAssets), 0 | ||
| } | ||
| } |
There was a problem hiding this comment.
Have you considered making the manifest fetch a group leg that starts the download on success, so every failure goes through the single g.Wait/isCollateral path instead of a separate stopPrep? I realize that would let a prep error beat the manifest NotFound, so keeping it inline may well be the better call.
There was a problem hiding this comment.
I kept it inline for the reason you gave. ate-api-server acts on the NotFound, and a group would let a prep error replace it. The download leg would also have to start from inside the manifest leg.
Also say that the asset fetches and image pulls a cancelled prep started keep running detached.
Part of #4023.
Restore fetched the snapshot manifest before it started the sandbox asset and OCI bundle prep. The prep reads only the request, so it now starts first and overlaps the manifest fetch. Only the snapshot download needs the manifest. A manifest failure cancels the prep leg and waits for it to return. Asset fetches and image pulls it started keep running detached, as they do when the snapshot download fails.
Testing: go test -race ./cmd/atelet/.... TestRestoreManifestFailureStopsPrep checks that the manifest fetch overlaps the prep, and that a manifest failure returns while the asset fetch is still running. The manifest-failure tests join the detached asset fetch before cleanup.
I used an AI agent to port this commit from our fork, address review comments, and draft this description. I reviewed the code and commit message.