feat: add structured logging, --dev flag, and snapshot network_overrides
- Add --dev flag to main that enables logrus caller info (file:line) for easier debugging without changing production log output - Wire firecracker SDK logger (WithLogger) and FIFO log file to both the golden VM and each clone machine so Firecracker's own logs are surfaced - Log the exact shell commands being run (cp --reflink, ip tuntap, ip link, firecracker binary) at Info level before each syscall/exec, making it straightforward to reproduce steps manually - Extract snapshot.go with loadSnapshotWithNetworkOverride: a direct PUT /snapshot/load call over the Unix socket that includes network_overrides, remapping the stored tap to the per-clone tap name (Firecracker v1.15+ feature not yet exposed by SDK v1.0.0) - Use firecracker.WithSnapshot + a Handlers.FcInit.Swap to replace the SDK's LoadSnapshotHandler with the above when Bridge != "none" Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
30
main.go
30
main.go
@@ -18,11 +18,36 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/kacerr/fc-orchestrator/orchestrator"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// strip --dev flag before subcommand routing
|
||||
dev := false
|
||||
filtered := os.Args[:1]
|
||||
for _, a := range os.Args[1:] {
|
||||
if a == "--dev" {
|
||||
dev = true
|
||||
} else {
|
||||
filtered = append(filtered, a)
|
||||
}
|
||||
}
|
||||
os.Args = filtered
|
||||
|
||||
if dev {
|
||||
log.SetReportCaller(true)
|
||||
log.SetFormatter(&log.TextFormatter{
|
||||
CallerPrettyfier: func(f *runtime.Frame) (string, string) {
|
||||
return "", fmt.Sprintf("%s:%d", filepath.Base(f.File), f.Line)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// figure out if we are running as root
|
||||
if os.Geteuid() == 0 {
|
||||
fmt.Println("Running with root/sudo privileges!")
|
||||
@@ -61,7 +86,10 @@ func main() {
|
||||
}
|
||||
|
||||
func usage() {
|
||||
fmt.Fprintf(os.Stderr, `Usage: %s <command> [args]
|
||||
fmt.Fprintf(os.Stderr, `Usage: %s [--dev] <command> [args]
|
||||
|
||||
Flags:
|
||||
--dev log format with source file:line (e.g. file="orchestrator.go:123")
|
||||
|
||||
Commands:
|
||||
init Download kernel + create Alpine rootfs
|
||||
|
||||
Reference in New Issue
Block a user