-
Notifications
You must be signed in to change notification settings - Fork 3
Description
The 2023 virt-docourse project is a serverless runtime for the Polycode backend.
The (name TBD) runtime will run code snippets in hardware virtualized virtual machines and must have the following properties:
- Written in Rust
- Support for
x86-64andaarch64 - Based on the rust-vmm crates
- Minimal footprint
- Minimal device model:
- Two emulated UARTs (a.k.a. serial ports)
- One virtio-mmio based networking interface (rust-vmm
virtio-net) - initramfs based root filesystems
- Support for the following languages:
- rustlang
- golang
Overall Architecture and Usage
The runtime is used to run code snippets for a well known, pre-defined and fixed set of programming languages.
Its inputs are a language, a code snippet contained in a file, and an API socket. With those arguments the runtime VMM starts a Linux VM which root file system is an initramfs image. The image contains all the needed language dependencies to build and run the code snippet file.
Inside the root file system, a custom serverless agent is the init process. It takes commands from the runtime VMM and executes them. The protocol between the serverless agent and the runtime VMM is a custom one, that can run over an emulated serial interface and is based on the SLIP protocol. Optionally, it can also run over a TCP/IP transport layer with e.g. virtio-net.
Initramfs generation
Initramfs images generation happens every time a new language or a new language version needs to be supported.
Images are generated and prepared in advance, and re-used for every VM instance running a certain language runtime (for a specific or the default version).
Images are based on container reference images for each language.
The image generation tool goes through the following steps:
- Pull the OCI container image from a container registry
- Unpack the container image on the local filesystem
- Amend and customize the image with all the needed serverless components (agent, etc)
- Generate a compressed initramfs image
The initramfs init process is the serverless agent.
$ initramfs-build --image rust:1.65.0 --initramfs rust-1.65.0.cpio.gz
Workload Execution
The runtime VMM starts a VM which root filesystem is the canonical initramfs for the desired language.
$ runtime-vmm --language rust --socket /tmp/UuId-12345678
The runtime VMM (based on lumper) initially listens for API commands on its Unix socket. The infrastructure control plane starts the actual VM and the guest kernel starts the serverless agent as the init process.
The VMM API start command passes the code snippet as its HTTP body and gets a Unix socket path back through the HTTP reply. The code snippet build or execution output is sent by the runtime VMM through this Unix socket.
Tasks
- Find a project name
- Define a serverless agent protocol
- Implement the serverless agent in Rust
- Add
virtio-nettolumper - Add support for standalone and separate (not embedded in the kernel) initramfs to
lumper - Add an HTTP based API to lumper
- Implement an initramfs generation tool in Rust
- Integrate the serverless runtime into Polycode
References
Metadata
Metadata
Assignees
Labels
Type
Projects
Status