Problem
Concurrent Pods using the same cold OCI artifact can independently download and import the same bytes. The check-and-pull/import sequences are not synchronized:
Snapshot import also removes the existing local name before starting. A cold burst can therefore perform N registry transfers/imports and race on the same local destination. A previous implementation identified this corruption class in vk-cocoon#1, but the protection was lost during the OCI-path rewrite.
The provider already has the desired singleflight pattern for fork snapshots in ensureForkSnapshot.
Proposed scope
- Add provider-owned keyed singleflight around the complete local-check + transfer/import + post-check sequence.
- Use separate key namespaces for snapshots and images, keyed by local destination/ref.
- Keep the local-hit fast path and let different artifacts import concurrently.
- Detach shared work from an individual CreatePod cancellation, with a bounded provider-lifecycle context.
- Preserve force-pull semantics: concurrent force requests share one active import, while a later force request can import again.
Acceptance criteria
- 16 concurrent cold requests for one snapshot produce one registry stream and one snapshot import.
- 16 concurrent cold requests for one cloud image produce one registry stream and one image import.
- Different refs are not serialized behind each other.
- A local cache hit performs no transfer or import.
- Cancelling one waiter does not cancel shared work for remaining callers.
- A shared failure reaches every waiter and a later call can retry successfully.
- Tests pass under
go test -race.
- A cold-cache burst benchmark records registry bytes, import process count, and CreatePod p95 before and after.
Problem
Concurrent Pods using the same cold OCI artifact can independently download and import the same bytes. The check-and-pull/import sequences are not synchronized:
ensureSnapshotensureRunImagesnapshots/puller.goSnapshot import also removes the existing local name before starting. A cold burst can therefore perform N registry transfers/imports and race on the same local destination. A previous implementation identified this corruption class in vk-cocoon#1, but the protection was lost during the OCI-path rewrite.
The provider already has the desired singleflight pattern for fork snapshots in
ensureForkSnapshot.Proposed scope
Acceptance criteria
go test -race.