Skip to content

snapshots: import and reuse locally exported chains - #14051

Merged
sipsma merged 17 commits into
mainfrom
sipsma/remote-cache-snapshot-chains
Sep 21, 2026
Merged

sipsma merged 17 commits into
mainfrom
sipsma/remote-cache-snapshot-chains

Conversation

@sipsma

@sipsma sipsma commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

A locally built snapshot could be exported and then applied again on import even while the original snapshot was still present. Reuse paths could also return handles or providers whose resources were no longer owned through consumption.

This adds supplied-provider ImportChain using the same layer helper as image import. Imports prefer an existing snapshot, then local bytes, then the provider. Exports register the descriptor actually returned, including requested compression and omitted-root keys, in the existing persisted reuse indexes.

Each returned ref or provider retains independent transfer ownership. Import/export waits honor cancellation. Prepared-image ownership uses the existing arbitrary-cache release hook, with late completion cleanup included in cache shutdown accounting. Startup removes only marked prior-process transfer leases after durable owners are restored. No storage format changes are needed.

Depends on #14050 and its engine/cache foundations. This operates below Container, Directory and File. The broader goal remains caching all persistable results; this PR makes no new type-eligibility decision and adds no remote service, foreign-result learning, or recipe execution. The design and implementation record records the boundary and remaining decisions.

Validation:

  • Real local snapshot/content stores and containerd GC: 15 focused snapshot tests passed under race instrumentation. Cases cover shared-prefix reuse, local export/import, pruning, partial source/apply failure, cancellation, historical blob loss and actual lease ownership.
  • Focused DagQL race checks passed 15 tests; core passed six selected typed persistence/module regressions. The refined clean-restart witness and prepared/original/rewritten provider race checks passed. Server startup compiled.
  • The restart witness clears manager metadata before SQLite hydration, preserves Container/Directory/File data, and reimports the original snapshot ID with no additional provider reads or applies. It removes the obsolete transfer lease while preserving three durable owners and an unrelated temporary lease. This is an in-process SQLite/cache/manager reopen over real stores, not a daemon or Bolt reopen test.
  • Three private production controls built successfully and failed the intended assertions: missing export registration, wrong omitted-root normalization, and missing startup lease deletion.
  • dagger --env dev check tla-check:quick: all 18 existing shapes passed. dagger --env dev call tla-check some --configs=snapshot_import,snapshot_export: both names passed through the runner. Final direct TLC runs, after the owner-content assertion refinement, passed 475,119 and 5,185,181 distinct states in 4.51s and 24.80s. The new component has named reachability and deliberate-break evidence; existing CacheLifecycle source/configs are unchanged. The model does not establish concurrent producer cancellation, arbitrary-cache completion or startup restoration; focused Go checks cover those paths.

No full Go/TLA suite or remote-service integration was run. Checks were selected as the source changed; final documentation/import grouping did not repeat successful behavior checks. The model README records bounds and source-qualified evidence.

Recorded focused Go commands

The physical-store binaries ran as root, with no skipped acceptance cases. Commands below retain the artifact paths used by the recorded runs. Core was rebuilt for the startup cleanup refinement.

go test -race -c -o /tmp/snapshot-foundations-implementation-20260905/implementer/snapshots-race.test ./engine/snapshots
sudo -n /tmp/snapshot-foundations-implementation-20260905/implementer/snapshots-race.test -test.v -test.timeout=5m '-test.run=TestImportChain|TestImportImageSharesChainReuse|TestExportChain|TestApplySnapshotDiff|TestAttachLease'
go test -race -v -count=1 -timeout=5m -run 'TestCacheArbitrary|TestCacheSnapshotOwnerLeaseSyncDefersSessionCleanup|TestCachePersistenceImportHydratesSnapshotMetadataAndSyncsOwnerLeases|TestPersistedSelfCodecScalarRoundTrip|TestPersistedSelfCodecNestedListRoundTrip|TestListResults' ./dagql
go test -race -c -o /tmp/snapshot-foundations-implementation-20260905/implementer/core-race.test ./core
sudo -n /tmp/snapshot-foundations-implementation-20260905/implementer/core-race.test -test.v -test.timeout=5m '-test.run=TestSnapshotTransferTypedAdoptionAndRestart|TestContainerRestoreSnapshotOwnershipAndRelease|TestContainerPersistedDetachedFileAndDirectoryPaths|TestModuleObjectPersistedResultRefsRoundTrip|TestModulePersistedTypeDefsRoundTripPreservesNullableValidity|TestModuleSourcePersistenceRetainsSelfCallsCapability'
go test -race -c -o /tmp/snapshot-foundations-implementation-20260905/implementer/core-restart-race.test ./core
sudo -n /tmp/snapshot-foundations-implementation-20260905/implementer/core-restart-race.test -test.v -test.timeout=5m -test.run=TestSnapshotTransferTypedAdoptionAndRestart
go test -race -c -o /tmp/snapshot-foundations-implementation-20260905/implementer/prepared-race.test ./engine/engineutil
sudo -n /tmp/snapshot-foundations-implementation-20260905/implementer/prepared-race.test -test.v -test.timeout=5m '-test.run=TestPreparedImageCacheOwnsProvider|TestPreparedImageCanceledLateCompletion'
go test -race -c -o /tmp/snapshot-foundations-implementation-20260905/implementer/assembled-race.test ./engine/engineutil/imageexport
sudo -n /tmp/snapshot-foundations-implementation-20260905/implementer/assembled-race.test -test.v -test.timeout=5m -test.run=TestAssembledProviderLifetime
go test -run '^$' ./engine/server

@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from 50016de to 9bebd3a Compare September 9, 2026 22:09
@sipsma
sipsma requested review from a team as code owners September 9, 2026 23:26
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from 9bebd3a to 62d62bd Compare September 9, 2026 23:32
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from 62d62bd to d709b70 Compare September 18, 2026 19:48
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from d709b70 to 31f7c8d Compare September 18, 2026 19:56
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from 31f7c8d to a4f7b28 Compare September 18, 2026 20:55
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from a4f7b28 to 612f0fc Compare September 19, 2026 02:24
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from 612f0fc to ce8895c Compare September 19, 2026 03:42
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from ce8895c to e982b14 Compare September 19, 2026 04:52
Base automatically changed from sipsma/remote-cache-container-part-persistence to main September 19, 2026 05:11
Specify supplied-source import, local export reuse, and resource ownership. Keep recipe reconstruction separate from this snapshot work.

Signed-off-by: Erik Sipsma <[email protected]>
Model import reuse, partial resource attachment, export ownership, and pruning independently of the result cache. Register the component without changing existing cache model sources or configuration selection.

Signed-off-by: Erik Sipsma <[email protected]>
Carry independent selection evidence through fetch and apply. Assert terminal producer cleanup and record measured control and reachability results.

Signed-off-by: Erik Sipsma <[email protected]>
Start local execution with an ordinary snapshot owner. Check present content retained for continuing owners and record the new witness and control.

Signed-off-by: Erik Sipsma <[email protected]>
Share layer reuse and apply with image import. Pin transfer resources through ref adoption and provider consumption. Register the selected local export encoding under its actual import prefix, including omitted roots.

Signed-off-by: Erik Sipsma <[email protected]>
Use cancelable per-snapshot exclusion. Exercise real stores, resource attachment, pruning, partial writes, mounted failures, provider copies, typed adoption, and restart.

Signed-off-by: Erik Sipsma <[email protected]>
Publish arbitrary completion under the cache lock and take abandoned cleanup once. Keep initializer cleanup visible to Close with an independent operation token. Verify cancellation, replacement, remaining waiters, and prepared image leases.

Signed-off-by: Erik Sipsma <[email protected]>
Record reusable chain import, export indexing, and provider ownership. Describe startup cleanup after durable owner restoration. Keep recipe decisions separate and state the limits of the local evidence.

Signed-off-by: Erik Sipsma <[email protected]>
Check the native bind operation and its cleanup before opening a physical store. Skip only permission failures so root without mount capability does not enter transfer tests.

Signed-off-by: Erik Sipsma <[email protected]>
Observe caller completion while waiting for image readiness. Fail immediately on an early result, including nil, while retaining the cancellation and ownership assertions after successful setup.

Signed-off-by: Erik Sipsma <[email protected]>
Retain the import flow and out-of-lock cleanup probes with local explanations. Normalize import groups and express the existing root fixture choices as a switch.

Signed-off-by: Erik Sipsma <[email protected]>
Fresh dagger generate go-sdk:generate on this branch: the two snapshot
configuration map entries and the modelFiles helper move the source-map
lines.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the sipsma/remote-cache-snapshot-chains branch from e982b14 to 87a8043 Compare September 19, 2026 05:11
@sipsma
sipsma merged commit 9282dfa into main Sep 21, 2026
86 checks passed
@sipsma
sipsma deleted the sipsma/remote-cache-snapshot-chains branch September 21, 2026 19:09
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.

3 participants