1
0
forked from wrenn/wrenn

Rename AGENT_*/CP_LISTEN_ADDR env vars to WRENN_* prefix

AGENT_FILES_ROOTDIR → WRENN_DIR, AGENT_LISTEN_ADDR → WRENN_HOST_LISTEN_ADDR,
AGENT_CP_URL → WRENN_CP_URL, AGENT_HOST_INTERFACE → WRENN_HOST_INTERFACE,
CP_LISTEN_ADDR → WRENN_CP_LISTEN_ADDR. Consolidates all env vars under a
consistent WRENN_ namespace.
This commit is contained in:
2026-03-29 00:30:20 +06:00
parent 75b28ed899
commit 906cc42d13
6 changed files with 25 additions and 29 deletions

View File

@ -5,13 +5,13 @@ DATABASE_URL=postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable
REDIS_URL=redis://localhost:6379/0 REDIS_URL=redis://localhost:6379/0
# Control Plane # Control Plane
CP_LISTEN_ADDR=:8080 WRENN_CP_LISTEN_ADDR=:8080
# Host Agent # Host Agent
AGENT_LISTEN_ADDR=:50051 WRENN_HOST_LISTEN_ADDR=:50051
AGENT_FILES_ROOTDIR=/var/lib/wrenn WRENN_DIR=/var/lib/wrenn
AGENT_HOST_INTERFACE=eth0 WRENN_HOST_INTERFACE=eth0
AGENT_CP_URL=http://localhost:8080 WRENN_CP_URL=http://localhost:8080
# Lago (billing — external service) # Lago (billing — external service)
LAGO_API_URL=http://localhost:3000 LAGO_API_URL=http://localhost:3000

View File

@ -51,12 +51,12 @@ Copy `.env.example` to `.env` and edit:
DATABASE_URL=postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable DATABASE_URL=postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable
# Control plane # Control plane
CP_LISTEN_ADDR=:8000 WRENN_CP_LISTEN_ADDR=:8000
CP_HOST_AGENT_ADDR=http://localhost:50051 CP_HOST_AGENT_ADDR=http://localhost:50051
# Host agent # Host agent
AGENT_LISTEN_ADDR=:50051 WRENN_HOST_LISTEN_ADDR=:50051
AGENT_FILES_ROOTDIR=/var/lib/wrenn WRENN_DIR=/var/lib/wrenn
``` ```
### Run ### Run
@ -69,7 +69,7 @@ make migrate-up
./builds/wrenn-cp ./builds/wrenn-cp
``` ```
Control plane listens on `CP_LISTEN_ADDR` (default `:8000`). Control plane listens on `WRENN_CP_LISTEN_ADDR` (default `:8000`).
### Host registration ### Host registration
@ -87,16 +87,16 @@ Hosts must be registered with the control plane before they can serve sandboxes.
2. **Start the host agent** with the registration token and its externally-reachable address: 2. **Start the host agent** with the registration token and its externally-reachable address:
```bash ```bash
sudo AGENT_CP_URL=http://cp-host:8000 \ sudo WRENN_CP_URL=http://cp-host:8000 \
./builds/wrenn-agent \ ./builds/wrenn-agent \
--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_FILES_ROOTDIR/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 `$WRENN_DIR/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
sudo AGENT_CP_URL=http://cp-host:8000 \ sudo WRENN_CP_URL=http://cp-host:8000 \
./builds/wrenn-agent --address 10.0.1.5:50051 ./builds/wrenn-agent --address 10.0.1.5:50051
``` ```
@ -107,7 +107,7 @@ Hosts must be registered with the control plane before they can serve sandboxes.
``` ```
Then restart the agent with the new token. Then restart the agent with the new token.
The agent sends heartbeats to the control plane every 30 seconds. Host agent listens on `AGENT_LISTEN_ADDR` (default `:50051`). The agent sends heartbeats to the control plane every 30 seconds. Host agent listens on `WRENN_HOST_LISTEN_ADDR` (default `:50051`).
### Rootfs images ### Rootfs images

View File

@ -45,13 +45,13 @@ func main() {
// Clean up any stale dm-snapshot devices from a previous crash. // Clean up any stale dm-snapshot devices from a previous crash.
devicemapper.CleanupStaleDevices() devicemapper.CleanupStaleDevices()
listenAddr := envOrDefault("AGENT_LISTEN_ADDR", ":50051") listenAddr := envOrDefault("WRENN_HOST_LISTEN_ADDR", ":50051")
rootDir := envOrDefault("AGENT_FILES_ROOTDIR", "/var/lib/wrenn") rootDir := envOrDefault("WRENN_DIR", "/var/lib/wrenn")
cpURL := os.Getenv("AGENT_CP_URL") cpURL := os.Getenv("WRENN_CP_URL")
tokenFile := filepath.Join(rootDir, "host.jwt") tokenFile := filepath.Join(rootDir, "host.jwt")
if cpURL == "" { if cpURL == "" {
slog.Error("AGENT_CP_URL environment variable is required") slog.Error("WRENN_CP_URL environment variable is required")
os.Exit(1) os.Exit(1)
} }
if *advertiseAddr == "" { if *advertiseAddr == "" {
@ -61,17 +61,13 @@ func main() {
// Expand base images to the standard disk size (sparse, no extra physical // Expand base images to the standard disk size (sparse, no extra physical
// disk). This ensures dm-snapshot sandboxes see the full size from boot. // disk). This ensures dm-snapshot sandboxes see the full size from boot.
imagesDir := filepath.Join(rootDir, "images") if err := sandbox.EnsureImageSizes(rootDir, sandbox.DefaultDiskSizeMB); err != nil {
if err := sandbox.EnsureImageSizes(imagesDir, sandbox.DefaultDiskSizeMB); err != nil {
slog.Error("failed to expand base images", "error", err) slog.Error("failed to expand base images", "error", err)
os.Exit(1) os.Exit(1)
} }
cfg := sandbox.Config{ cfg := sandbox.Config{
KernelPath: filepath.Join(rootDir, "kernels", "vmlinux"), WrennDir: rootDir,
ImagesDir: filepath.Join(rootDir, "images"),
SandboxesDir: filepath.Join(rootDir, "sandboxes"),
SnapshotsDir: filepath.Join(rootDir, "snapshots"),
} }
mgr := sandbox.New(cfg) mgr := sandbox.New(cfg)

View File

@ -28,7 +28,7 @@ func Load() Config {
return Config{ return Config{
DatabaseURL: envOrDefault("DATABASE_URL", "postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable"), DatabaseURL: envOrDefault("DATABASE_URL", "postgres://wrenn:wrenn@localhost:5432/wrenn?sslmode=disable"),
RedisURL: envOrDefault("REDIS_URL", "redis://localhost:6379/0"), RedisURL: envOrDefault("REDIS_URL", "redis://localhost:6379/0"),
ListenAddr: envOrDefault("CP_LISTEN_ADDR", ":8080"), ListenAddr: envOrDefault("WRENN_CP_LISTEN_ADDR", ":8080"),
JWTSecret: os.Getenv("JWT_SECRET"), JWTSecret: os.Getenv("JWT_SECRET"),
OAuthGitHubClientID: os.Getenv("OAUTH_GITHUB_CLIENT_ID"), OAuthGitHubClientID: os.Getenv("OAUTH_GITHUB_CLIENT_ID"),

View File

@ -17,7 +17,7 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
// tokenFile is the JSON format persisted to AGENT_FILES_ROOTDIR/host.jwt. // tokenFile is the JSON format persisted to WRENN_DIR/host.jwt.
type tokenFile struct { type tokenFile struct {
HostID string `json:"host_id"` HostID string `json:"host_id"`
JWT string `json:"jwt"` JWT string `json:"jwt"`

View File

@ -16,7 +16,7 @@
# image_name — Directory name under images dir (e.g. "waitlist") # image_name — Directory name under images dir (e.g. "waitlist")
# #
# Output: # Output:
# ${AGENT_FILES_ROOTDIR}/images/<image_name>/rootfs.ext4 # ${WRENN_DIR}/images/<image_name>/rootfs.ext4
# #
# Requires: docker, mkfs.ext4, resize2fs, e2fsck, make (for building envd), curl (for tini download) # Requires: docker, mkfs.ext4, resize2fs, e2fsck, make (for building envd), curl (for tini download)
# Sudo is used only for mount/umount/copy-into-image operations. # Sudo is used only for mount/umount/copy-into-image operations.
@ -25,8 +25,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_FILES_ROOTDIR="${AGENT_FILES_ROOTDIR:-/var/lib/wrenn}" WRENN_DIR="${WRENN_DIR:-/var/lib/wrenn}"
AGENT_IMAGES_PATH="${AGENT_FILES_ROOTDIR}/images" WRENN_IMAGES_PATH="${WRENN_DIR}/images"
if [ $# -lt 2 ]; then if [ $# -lt 2 ]; then
echo "Usage: $0 <container> <image_name>" echo "Usage: $0 <container> <image_name>"
@ -35,7 +35,7 @@ fi
CONTAINER="$1" CONTAINER="$1"
IMAGE_NAME="$2" IMAGE_NAME="$2"
OUTPUT_DIR="${AGENT_IMAGES_PATH}/${IMAGE_NAME}" OUTPUT_DIR="${WRENN_IMAGES_PATH}/${IMAGE_NAME}"
OUTPUT_FILE="${OUTPUT_DIR}/rootfs.ext4" OUTPUT_FILE="${OUTPUT_DIR}/rootfs.ext4"
MOUNT_DIR="/tmp/wrenn-rootfs-build" MOUNT_DIR="/tmp/wrenn-rootfs-build"
TAR_FILE="/tmp/wrenn-rootfs-export-${IMAGE_NAME}.tar" TAR_FILE="/tmp/wrenn-rootfs-export-${IMAGE_NAME}.tar"