Add experimental Void guest workflow and vsock agent
Make iterating on a Firecracker-friendly Void guest practical without replacing the Debian default image path. Add local Void rootfs build/register/verify plumbing, a language-agnostic dev package baseline, and guest SSH/work-disk hardening so new images use the runtime bundle key, keep a normal root bash environment, and repair stale nested /root layouts on restart. Replace the guest PING/PONG responder with an HTTP /healthz agent over vsock, rename the runtime bundle and config surface from ping helper to agent while still accepting the legacy keys, and route the post-SSH reminder through the new vm.health path. Validated with GOCACHE=/tmp/banger-gocache go test ./..., make build, bash -n customize.sh make-rootfs-void.sh, and git diff --check.
This commit is contained in:
parent
c8d9a122f9
commit
3ed78fdcfc
42 changed files with 2222 additions and 388 deletions
|
|
@ -1,23 +1,19 @@
|
|||
package firecracker
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
sdk "github.com/firecracker-microvm/firecracker-go-sdk"
|
||||
models "github.com/firecracker-microvm/firecracker-go-sdk/client/models"
|
||||
sdkvsock "github.com/firecracker-microvm/firecracker-go-sdk/vsock"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"banger/internal/vsockping"
|
||||
"banger/internal/vsockagent"
|
||||
)
|
||||
|
||||
type MachineConfig struct {
|
||||
|
|
@ -212,37 +208,12 @@ func newLogger(base *slog.Logger) *logrus.Entry {
|
|||
return logrus.NewEntry(logger)
|
||||
}
|
||||
|
||||
func HealthVSock(ctx context.Context, logger *slog.Logger, socketPath string) error {
|
||||
return vsockagent.Health(ctx, logger, socketPath)
|
||||
}
|
||||
|
||||
func PingVSock(ctx context.Context, logger *slog.Logger, socketPath string) error {
|
||||
conn, err := sdkvsock.DialContext(
|
||||
ctx,
|
||||
socketPath,
|
||||
vsockping.Port,
|
||||
sdkvsock.WithRetryTimeout(3*time.Second),
|
||||
sdkvsock.WithRetryInterval(100*time.Millisecond),
|
||||
sdkvsock.WithLogger(newLogger(logger)),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
_ = conn.SetDeadline(deadline)
|
||||
} else {
|
||||
_ = conn.SetDeadline(time.Now().Add(3 * time.Second))
|
||||
}
|
||||
|
||||
if _, err := io.WriteString(conn, vsockping.RequestLine); err != nil {
|
||||
return err
|
||||
}
|
||||
line, err := bufio.NewReader(conn).ReadString('\n')
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if strings.TrimSpace(line) != strings.TrimSpace(vsockping.ResponseLine) {
|
||||
return fmt.Errorf("unexpected vsock response %q", strings.TrimSpace(line))
|
||||
}
|
||||
return nil
|
||||
return HealthVSock(ctx, logger, socketPath)
|
||||
}
|
||||
|
||||
type slogHook struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue