Conversation
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR adds snapshotContainer() API and local dev Docker implementation for full container snapshots, alongside renaming the existing directory snapshot fields for clarity.
- [MEDIUM] No stale container snapshot image cleanup:
warnAboutStaleSnapshotVolumeshandles stale Docker volumes for directory snapshots, but there's no equivalent mechanism for staleworkerd-container-snap-*images. Over time in local dev, these could accumulate. Not blocking, but worth tracking. - [LOW] Missing
KJ_LOGinsnapshotContainer:snapshotDirectorylogsKJ_LOG(INFO, "created snapshot volume", ...)on success, butsnapshotContainerhas no corresponding log entry. Minor consistency/debugging gap.
This review was generated by an AI assistant and may contain inaccuracies.
|
I'm Bonk, and I've done a quick review of your PR. This PR adds Summary of findings posted to PR #6430:
Things that looked good:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6430 +/- ##
==========================================
+ Coverage 70.70% 70.77% +0.07%
==========================================
Files 427 427
Lines 117263 117905 +642
Branches 18903 18943 +40
==========================================
+ Hits 82905 83442 +537
- Misses 23102 23193 +91
- Partials 11256 11270 +14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
20eadae to
60182d2
Compare
|
Split out the local dev ( |
60182d2 to
564d7dd
Compare
| } | ||
| interface ContainerSnapshot { | ||
| id: string; | ||
| size: number; |
There was a problem hiding this comment.
Hmm, why does this size property need to be here? Why doesn't the container service get the size along with the content? What happens if an application falsifies the size?
There was a problem hiding this comment.
What happens if an application falsifies the size?
size here is functionally read-only, it is only provided to the user so they know how large the snapshot is (for whatever purpose). It's not read or used on the restore path: only the id is.
There was a problem hiding this comment.
Why does it get passed back to the container capnp API then? You added code in this PR to validate the size passed back from the app. Why not just ignore the size passed back from the app?
There was a problem hiding this comment.
Yes you're right -- good catch. I'll remove it (and the validation).
snapshotContainer creates a "full container" snapshot, which includes the entire disk/filesystem and (optionally) the state of the container memory when the snapshot is created. Unlike directory snapshots, only a single container snapshot can be restored (but multiple directory snapshots can be restored alongside a container snapshot).
564d7dd to
83a16ed
Compare
| directorySnapshots @6 :List(DirectorySnapshotRestoreParams); | ||
| # Directory snapshots to restore before the container starts. | ||
|
|
||
| containerSnapshot @7 :ContainerSnapshot; |
There was a problem hiding this comment.
Let's document that the size is ignored.
What about the name? Does the container runtime actually use that, or just the id?
There was a problem hiding this comment.
If the container runtime only uses the id, maybe this should just be :Text and it's just the ID alone?
There was a problem hiding this comment.
I considered dropping name as well but I could see that being useful for debugging.
If the container runtime only uses the id, maybe this should just be :Text and it's just the ID alone?
I'm not opposed but the idea behind this was that the user could pass the same object they got back from snapshotContainer() (or snapshotDirectory()) right back into container.start() without needing to know any details about the type (but the fields are there for inspection if needed).
There was a problem hiding this comment.
The JS API can still allow that, I'm just talking about the underlying capnp API.
I am worried that we are passing back information that the application could have tampered with, and it would be easy to accidentally write code in the containers runtime that doesn't realize this information can be tampered with. If we pass the ID raw, then that risk seems greatly reduced.
This is part 2 of the containers snapshot API, following up from #6376 which implemented
snapshotDirectory()to create a "directory snapshot". This PR implementssnapshotContainer()to create a "full container" snapshot.Conceptually, a "directory snapshot" can be thought of as an (immutable) Docker volume which can be mounted (restored) to other containers. More than one directory snapshot can be restored to a container.
A "full container snapshot" can be thought of as creating a new Docker image based on the current state of the container (this is how it is even implemented in local dev, using the Docker commit API). Only one full container snapshot can be restored into a new container, which effectively replaces the image of the container.
Directory snapshots can be restored alongside a full container snapshot.
NOTE: This PR intentionally does not implement full container snapshots in local dev. That will be deferred to a future PR (cc @danlapid).
cc @IRCody @spahl