forked from wrenn/wrenn
Restructure pause to: block new operations (StatusPausing), drain proxy connections with 5s grace, force-close remaining via context cancellation, drop page cache, inflate balloon, then freeze vCPUs. Previously connections could arrive during the pause window and API operations weren't blocked. Handle UFFD_EVENT_REMOVE/UNMAP/REMAP/FORK gracefully instead of crashing the UFFD server. These events fire during balloon deflation on snapshot restore, killing the page fault handler and preventing VM boot. Also adds ConnTracker.ForceClose() with cancellable context propagated through the proxy handler, so lingering proxy connections are actively terminated rather than left dangling.
36 lines
786 B
Go
36 lines
786 B
Go
package models
|
|
|
|
import (
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
// SandboxStatus represents the current state of a sandbox.
|
|
type SandboxStatus string
|
|
|
|
const (
|
|
StatusPending SandboxStatus = "pending"
|
|
StatusRunning SandboxStatus = "running"
|
|
StatusPausing SandboxStatus = "pausing"
|
|
StatusPaused SandboxStatus = "paused"
|
|
StatusStopped SandboxStatus = "stopped"
|
|
StatusError SandboxStatus = "error"
|
|
)
|
|
|
|
// Sandbox holds all state for a running sandbox on this host.
|
|
type Sandbox struct {
|
|
ID string
|
|
Status SandboxStatus
|
|
TemplateTeamID [16]byte
|
|
TemplateID [16]byte
|
|
VCPUs int
|
|
MemoryMB int
|
|
TimeoutSec int
|
|
SlotIndex int
|
|
HostIP net.IP
|
|
RootfsPath string
|
|
CreatedAt time.Time
|
|
LastActiveAt time.Time
|
|
Metadata map[string]string
|
|
}
|