Consolidate host agent path env vars into single AGENT_FILES_ROOTDIR
Replace AGENT_KERNEL_PATH, AGENT_IMAGES_PATH, AGENT_SANDBOXES_PATH, AGENT_SNAPSHOTS_PATH, and AGENT_TOKEN_FILE with a single AGENT_FILES_ROOTDIR (default /var/lib/wrenn) that derives all subdirectory paths automatically.
This commit is contained in:
@ -10,13 +10,9 @@ CP_HOST_AGENT_ADDR=localhost:50051
|
|||||||
|
|
||||||
# Host Agent
|
# Host Agent
|
||||||
AGENT_LISTEN_ADDR=:50051
|
AGENT_LISTEN_ADDR=:50051
|
||||||
AGENT_KERNEL_PATH=/var/lib/wrenn/kernels/vmlinux
|
AGENT_FILES_ROOTDIR=/var/lib/wrenn
|
||||||
AGENT_IMAGES_PATH=/var/lib/wrenn/images
|
|
||||||
AGENT_SANDBOXES_PATH=/var/lib/wrenn/sandboxes
|
|
||||||
AGENT_SNAPSHOTS_PATH=/var/lib/wrenn/snapshots
|
|
||||||
AGENT_HOST_INTERFACE=eth0
|
AGENT_HOST_INTERFACE=eth0
|
||||||
AGENT_CP_URL=http://localhost:8000
|
AGENT_CP_URL=http://localhost:8000
|
||||||
AGENT_TOKEN_FILE=/var/lib/wrenn/host-token
|
|
||||||
|
|
||||||
# Lago (billing — external service)
|
# Lago (billing — external service)
|
||||||
LAGO_API_URL=http://localhost:3000
|
LAGO_API_URL=http://localhost:3000
|
||||||
|
|||||||
@ -35,6 +35,9 @@ mkdir -p /var/lib/wrenn/images
|
|||||||
# Sandbox working directory
|
# Sandbox working directory
|
||||||
mkdir -p /var/lib/wrenn/sandboxes
|
mkdir -p /var/lib/wrenn/sandboxes
|
||||||
|
|
||||||
|
# Snapshots directory
|
||||||
|
mkdir -p /var/lib/wrenn/snapshots
|
||||||
|
|
||||||
# Enable IP forwarding
|
# Enable IP forwarding
|
||||||
sysctl -w net.ipv4.ip_forward=1
|
sysctl -w net.ipv4.ip_forward=1
|
||||||
```
|
```
|
||||||
@ -53,9 +56,7 @@ CP_HOST_AGENT_ADDR=http://localhost:50051
|
|||||||
|
|
||||||
# Host agent
|
# Host agent
|
||||||
AGENT_LISTEN_ADDR=:50051
|
AGENT_LISTEN_ADDR=:50051
|
||||||
AGENT_KERNEL_PATH=/var/lib/wrenn/kernels/vmlinux
|
AGENT_FILES_ROOTDIR=/var/lib/wrenn
|
||||||
AGENT_IMAGES_PATH=/var/lib/wrenn/images
|
|
||||||
AGENT_SANDBOXES_PATH=/var/lib/wrenn/sandboxes
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run
|
### Run
|
||||||
@ -91,7 +92,7 @@ Hosts must be registered with the control plane before they can serve sandboxes.
|
|||||||
--register <token-from-step-1> \
|
--register <token-from-step-1> \
|
||||||
--address 10.0.1.5:50051
|
--address 10.0.1.5:50051
|
||||||
```
|
```
|
||||||
On first startup the agent sends its specs (arch, CPU, memory, disk) to the control plane, receives a long-lived host JWT, and saves it to `AGENT_TOKEN_FILE` (default `/var/lib/wrenn/host-token`).
|
On first startup the agent sends its specs (arch, CPU, memory, disk) to the control plane, receives a long-lived host JWT, and saves it to `$AGENT_FILES_ROOTDIR/host-token`.
|
||||||
|
|
||||||
3. **Subsequent startups** don't need `--register` — the agent loads the saved JWT automatically:
|
3. **Subsequent startups** don't need `--register` — the agent loads the saved JWT automatically:
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path/filepath"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -39,18 +40,15 @@ func main() {
|
|||||||
devicemapper.CleanupStaleDevices()
|
devicemapper.CleanupStaleDevices()
|
||||||
|
|
||||||
listenAddr := envOrDefault("AGENT_LISTEN_ADDR", ":50051")
|
listenAddr := envOrDefault("AGENT_LISTEN_ADDR", ":50051")
|
||||||
kernelPath := envOrDefault("AGENT_KERNEL_PATH", "/var/lib/wrenn/kernels/vmlinux")
|
rootDir := envOrDefault("AGENT_FILES_ROOTDIR", "/var/lib/wrenn")
|
||||||
imagesPath := envOrDefault("AGENT_IMAGES_PATH", "/var/lib/wrenn/images")
|
|
||||||
sandboxesPath := envOrDefault("AGENT_SANDBOXES_PATH", "/var/lib/wrenn/sandboxes")
|
|
||||||
snapshotsPath := envOrDefault("AGENT_SNAPSHOTS_PATH", "/var/lib/wrenn/snapshots")
|
|
||||||
cpURL := os.Getenv("AGENT_CP_URL")
|
cpURL := os.Getenv("AGENT_CP_URL")
|
||||||
tokenFile := envOrDefault("AGENT_TOKEN_FILE", "/var/lib/wrenn/host-token")
|
tokenFile := filepath.Join(rootDir, "host-token")
|
||||||
|
|
||||||
cfg := sandbox.Config{
|
cfg := sandbox.Config{
|
||||||
KernelPath: kernelPath,
|
KernelPath: filepath.Join(rootDir, "kernels", "vmlinux"),
|
||||||
ImagesDir: imagesPath,
|
ImagesDir: filepath.Join(rootDir, "images"),
|
||||||
SandboxesDir: sandboxesPath,
|
SandboxesDir: filepath.Join(rootDir, "sandboxes"),
|
||||||
SnapshotsDir: snapshotsPath,
|
SnapshotsDir: filepath.Join(rootDir, "snapshots"),
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr := sandbox.New(cfg)
|
mgr := sandbox.New(cfg)
|
||||||
|
|||||||
@ -10,10 +10,10 @@
|
|||||||
#
|
#
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# container — Docker container name or ID to export
|
# container — Docker container name or ID to export
|
||||||
# image_name — Directory name under AGENT_IMAGES_PATH (e.g. "waitlist")
|
# image_name — Directory name under images dir (e.g. "waitlist")
|
||||||
#
|
#
|
||||||
# Output:
|
# Output:
|
||||||
# ${AGENT_IMAGES_PATH}/<image_name>/rootfs.ext4
|
# ${AGENT_FILES_ROOTDIR}/images/<image_name>/rootfs.ext4
|
||||||
#
|
#
|
||||||
# Requires: docker, mkfs.ext4, resize2fs, e2fsck, make (for building envd)
|
# Requires: docker, mkfs.ext4, resize2fs, e2fsck, make (for building envd)
|
||||||
# Sudo is used only for mount/umount/copy-into-image operations.
|
# Sudo is used only for mount/umount/copy-into-image operations.
|
||||||
@ -22,7 +22,8 @@ set -euo pipefail
|
|||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
|
||||||
AGENT_IMAGES_PATH="${AGENT_IMAGES_PATH:-/var/lib/wrenn/images}"
|
AGENT_FILES_ROOTDIR="${AGENT_FILES_ROOTDIR:-/var/lib/wrenn}"
|
||||||
|
AGENT_IMAGES_PATH="${AGENT_FILES_ROOTDIR}/images"
|
||||||
|
|
||||||
if [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
echo "Usage: $0 <container> <image_name>"
|
echo "Usage: $0 <container> <image_name>"
|
||||||
|
|||||||
Reference in New Issue
Block a user