-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add suppport for PuzzleFS images in the oci template #4483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This pull request didn't trigger Jenkins as its author isn't in the allow list. An organization member must perform one of the following:
Those commands are simple Github comments of the format: "jenkins: COMMAND" |
@hallyn could you please take a look? |
If this is all it takes, that's great. Huge +1 from me on making testing that much easier. |
It seems like the atomfs semantics changed in this commit, so I guess the atomfs mounts no longer work out of the box. @hallyn I'm wondering if I should add an |
Agreed, mount helper should be easily detected from media type. We could also support a simple toml file somewhere to customize over our defauls. To be clear: that's a nice-to-have, but not required for a commit to enable puzzlefs. --upper-dir (or, I think I prefer --persist-to, but maybe that's weird sounding) would be nice. Anyway let me set up a vm to test this in. |
Also I've noticed we set |
That's intentional: traditionally, OCI images are used for application containers. Of course we've been using them to ship RFS for hardware, so it may be worth revisiting that decision. |
Do you mind adding the pf-mount-helper binary and logic to choose the right helper based on the application/vnd..image.layer.squashfs vs application/vnd.puzzlefs.image.rootfs.*`to this patch? |
For context, this it my presentation at LPC 2024 where I show how to run an LXC container with PuzzleFS images. @hallyn I'm wondering what's the best approach here:
I think the solution with the least amount of changes would be to just call the atomfs/puzzlefs binaries (or maybe atomfs-lxc/puzzlefs-lxc so we can have wrapper scripts that do the overlay mounting) when we detect their corresponding media type and to change the mount-helper arguments to accept an overlay. That way, we don't need to add puzzlefs specific mount helpers in LXC. But maybe the solution with a generic overlay mount helper is more elegant, or even implement this logic into LXC itself. I mean, there already is @mihalicyn any thoughts on this? |
Having looked at the atomfs codebase, this wouldn't work because there are too many mountpoints being created. Having said this, I would either go with option 2 and add the necessary logic for creating an overlay in puzzlefs, or use the overlayfs syntax in lxc.rootfs.path for puzzlefs (if it's even possible), but not atomfs. I still don't like storing the puzzlefs mount helper script in lxc. |
Ok, no puzzlefs mount helper in lxc. What do you mean by atomfs makes too many mounts? It does hide them behind the final mount, right? |
Right, I just meant that we couldn't implement a generic overlayfs functionality in LXC because of the complex requirements that atomfs has. But now that I think about it, atomfs could mount a read-only overlay and then LXC could mount a writable overlay on top. I don't know whether we should go for this or not.
This could work for starting the container, but we also need to mount the rootfs in the LCX OCI template script itself, so it's not a good solution. What do you think we should do, @hallyn ? |
Honestly I think we are over complicating the issue. From lxc side, we should just say mount-helper api has to be: mount ocidir:image [-w writeable-dir] destdir. We make atomfs and puzzlefs honor those, and anybother mount helper which doesn't can provide its own wrapper script. |
This sounds reasonable, I'll go ahead and implement it this way. |
2368b8c
to
44cded3
Compare
The mount-helper is called like this: mount-helper mount --writable <oci_dir>:<oci_name> <mountpoint> mount-helper umount <mountpoint> I've added the support for the `--writable` flag that creates a writable overlay on top of a PuzzleFS mountpoint (used as a lowerdir). This requires root privileges. I've also added the support for the `umount` subcommand which detects whether the puzzlefs filesystem was mounted as a read-only fuse driver or whether an overlay was created on top of it, and handles the unmounting accordingly. Unmounting an overlay requires root privileges. I've implemented the changes on the LXC side in [1]. [1] lxc/lxc#4483 Signed-off-by: Ariel Miculas-Trif <amiculas@cisco.com>
It needs to be spelled out somewhere what the writeable directory will be. It looks like puzzlefs is putting it under |
For a privileged container |
Right. |
I have the following error with the latest changes:
This occurs when I start the container:
|
The mount-helper is called like this: mount-helper mount --writable <oci_dir>:<oci_name> <mountpoint> mount-helper umount <mountpoint> I've added the support for the `--writable` flag that creates a writable overlay on top of a PuzzleFS mountpoint (used as a lowerdir). This requires root privileges. I've also added the support for the `umount` subcommand which detects whether the puzzlefs filesystem was mounted as a read-only fuse driver or whether an overlay was created on top of it, and handles the unmounting accordingly. Unmounting an overlay requires root privileges. I've implemented the changes on the LXC side in [1]. [1] lxc/lxc#4483 Signed-off-by: Ariel Miculas-Trif <amiculas@cisco.com>
PuzzleFS images (media type 'application/vnd.puzzlefs.image.rootfs.v1') can be mounted in a similar way to squashfs images, we just have to detect the type and reu 8000 se the existing code for providing a mount helper. PuzzleFS is a next-generation container filesystem [1] with several benefits, such as reduced duplication, reproducible image builds, direct mounting support and memory safety guarantees. Since PuzzleFS currently doesn't provide an image config, also add support for empty image configs, they are supported by the OCI spec [2]. The MOUNT_HELPER is now passed a `--persist <upperdir>` flag, so it knows that it needs to create an overlay. This is needed because LXC expects a writable rootfs and both atomfs and puzzlefs are read-only filesystems. Example: ``` $ sudo env PATH=$PATH build/src/lxc/tools/lxc-create --name mycontainer -t \ oci -- --url oci:/$HOME/.local/share/puzzlefs/pfs_ubuntu:eg --no-cache $ sudo build/src/lxc/tools/lxc-start --name mycontainer --foreground /bin/bash ``` --no-cache is needed for puzzlefs until [3] is solved [1] https://github.com/project-machine/puzzlefs [2] https://github.com/opencontainers/image-spec/blob/main/manifest.md#image-manifest [3] project-machine/puzzlefs#131 Signed-off-by: Ariel Miculas-Trif <amiculas@cisco.com>
44cded3
to
3764c19
Compare
Can you show the full logs? (lxc-start [....] -l trace -o debug.out) The error you quote says "continuing", so I don't think it's the actual problem... |
Well the container does start... |
Here's the log at level TRACE: https://pastebin.com/Xhmaf9Wr |
Hm, so it did start, appears to have immediately exited:
Hm, looking at the puzzlefs and lxc patches, the mount-helper is not being passed --writable, but puzzlefs still requires --writable as well as --persist. So my guess is your container is actually readonly right now? I was actually suggesting that --writable not be a bool, but itself accept the string for the upperdir. That's all bikeshedding though, I'm fine if you want to say that
|
That's because I pressed Ctrl-D right after it started
It's enough to pass
I just copied the flags from atomfs, so we can keep the existing atomfs implementation as it is. Of course, if there's a better way, I'm not opposed to changing the flags. The current puzzlefs behavior is (not need to pass
|
Turns out the message
wasn't related to my changes, but to another mountpoint I had in my system. So all works well. Do you want me to make any changes to the |
No, while I would prefer that behavior, let's keep changing that as a separate task. So just be clear, we can merge both this and the puzzlefs patch and all will work? |
Thanks! |
Thanks, @hallyn !
you mean renaming
Yes, it all works. |
Yeah. It's fine as is. If we decide it's confusing we can rename it separately later. |
The mount-helper is called like this: mount-helper mount --writable <oci_dir>:<oci_name> <mountpoint> mount-helper umount <mountpoint> I've added the support for the `--writable` flag that creates a writable overlay on top of a PuzzleFS mountpoint (used as a lowerdir). This requires root privileges. I've also added the support for the `umount` subcommand which detects whether the puzzlefs filesystem was mounted as a read-only fuse driver or whether an overlay was created on top of it, and handles the unmounting accordingly. Unmounting an overlay requires root privileges. I've implemented the changes on the LXC side in [1]. [1] lxc/lxc#4483 Signed-off-by: Ariel Miculas-Trif <amiculas@cisco.com>
PuzzleFS images (media type 'application/vnd.puzzlefs.image.rootfs.v1') can be mounted in a similar way to squashfs images, we just have to detect the type and reuse the existing code for providing a mount helper. PuzzleFS is a next-generation container filesystem [1] with several benefits, such as reduced duplication, reproducible image builds, direct mounting support and memory safety guarantees.
Since PuzzleFS currently doesn't provide an image config, also add support for empty image configs, they are supported by the OCI spec [2].
[1] https://github.com/project-machine/puzzlefs
[2] https://github.com/opencontainers/image-spec/blob/main/manifest.md#image-manifest