1
0
forked from wrenn/wrenn
Co-authored-by: Tasnim Kabir Sadik <tksadik@omukk.dev>

Reviewed-on: wrenn/wrenn#50
This commit is contained in:
2026-05-24 21:10:37 +00:00
parent 4707f16c76
commit 05ddf62399
203 changed files with 15815 additions and 9344 deletions

File diff suppressed because it is too large Load Diff

View File

@ -119,6 +119,9 @@ const (
// HostAgentServiceConnectProcessProcedure is the fully-qualified name of the HostAgentService's
// ConnectProcess RPC.
HostAgentServiceConnectProcessProcedure = "/hostagent.v1.HostAgentService/ConnectProcess"
// HostAgentServiceGetTemplateSizeProcedure is the fully-qualified name of the HostAgentService's
// GetTemplateSize RPC.
HostAgentServiceGetTemplateSizeProcedure = "/hostagent.v1.HostAgentService/GetTemplateSize"
)
// HostAgentServiceClient is a client for the hostagent.v1.HostAgentService service.
@ -193,6 +196,11 @@ type HostAgentServiceClient interface {
KillProcess(context.Context, *connect.Request[gen.KillProcessRequest]) (*connect.Response[gen.KillProcessResponse], error)
// ConnectProcess re-attaches to a running process and streams its output.
ConnectProcess(context.Context, *connect.Request[gen.ConnectProcessRequest]) (*connect.ServerStreamForClient[gen.ConnectProcessResponse], error)
// GetTemplateSize returns the actual disk usage of a template's rootfs file.
// Used by the control plane to populate size_bytes for templates that have
// size 0 in the database (e.g. system base templates seeded before the
// rootfs was built).
GetTemplateSize(context.Context, *connect.Request[gen.GetTemplateSizeRequest]) (*connect.Response[gen.GetTemplateSizeResponse], error)
}
// NewHostAgentServiceClient constructs a client for the hostagent.v1.HostAgentService service. By
@ -380,6 +388,12 @@ func NewHostAgentServiceClient(httpClient connect.HTTPClient, baseURL string, op
connect.WithSchema(hostAgentServiceMethods.ByName("ConnectProcess")),
connect.WithClientOptions(opts...),
),
getTemplateSize: connect.NewClient[gen.GetTemplateSizeRequest, gen.GetTemplateSizeResponse](
httpClient,
baseURL+HostAgentServiceGetTemplateSizeProcedure,
connect.WithSchema(hostAgentServiceMethods.ByName("GetTemplateSize")),
connect.WithClientOptions(opts...),
),
}
}
@ -414,6 +428,7 @@ type hostAgentServiceClient struct {
listProcesses *connect.Client[gen.ListProcessesRequest, gen.ListProcessesResponse]
killProcess *connect.Client[gen.KillProcessRequest, gen.KillProcessResponse]
connectProcess *connect.Client[gen.ConnectProcessRequest, gen.ConnectProcessResponse]
getTemplateSize *connect.Client[gen.GetTemplateSizeRequest, gen.GetTemplateSizeResponse]
}
// CreateSandbox calls hostagent.v1.HostAgentService.CreateSandbox.
@ -561,6 +576,11 @@ func (c *hostAgentServiceClient) ConnectProcess(ctx context.Context, req *connec
return c.connectProcess.CallServerStream(ctx, req)
}
// GetTemplateSize calls hostagent.v1.HostAgentService.GetTemplateSize.
func (c *hostAgentServiceClient) GetTemplateSize(ctx context.Context, req *connect.Request[gen.GetTemplateSizeRequest]) (*connect.Response[gen.GetTemplateSizeResponse], error) {
return c.getTemplateSize.CallUnary(ctx, req)
}
// HostAgentServiceHandler is an implementation of the hostagent.v1.HostAgentService service.
type HostAgentServiceHandler interface {
// CreateSandbox boots a new microVM with the given configuration.
@ -633,6 +653,11 @@ type HostAgentServiceHandler interface {
KillProcess(context.Context, *connect.Request[gen.KillProcessRequest]) (*connect.Response[gen.KillProcessResponse], error)
// ConnectProcess re-attaches to a running process and streams its output.
ConnectProcess(context.Context, *connect.Request[gen.ConnectProcessRequest], *connect.ServerStream[gen.ConnectProcessResponse]) error
// GetTemplateSize returns the actual disk usage of a template's rootfs file.
// Used by the control plane to populate size_bytes for templates that have
// size 0 in the database (e.g. system base templates seeded before the
// rootfs was built).
GetTemplateSize(context.Context, *connect.Request[gen.GetTemplateSizeRequest]) (*connect.Response[gen.GetTemplateSizeResponse], error)
}
// NewHostAgentServiceHandler builds an HTTP handler from the service implementation. It returns the
@ -816,6 +841,12 @@ func NewHostAgentServiceHandler(svc HostAgentServiceHandler, opts ...connect.Han
connect.WithSchema(hostAgentServiceMethods.ByName("ConnectProcess")),
connect.WithHandlerOptions(opts...),
)
hostAgentServiceGetTemplateSizeHandler := connect.NewUnaryHandler(
HostAgentServiceGetTemplateSizeProcedure,
svc.GetTemplateSize,
connect.WithSchema(hostAgentServiceMethods.ByName("GetTemplateSize")),
connect.WithHandlerOptions(opts...),
)
return "/hostagent.v1.HostAgentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case HostAgentServiceCreateSandboxProcedure:
@ -876,6 +907,8 @@ func NewHostAgentServiceHandler(svc HostAgentServiceHandler, opts ...connect.Han
hostAgentServiceKillProcessHandler.ServeHTTP(w, r)
case HostAgentServiceConnectProcessProcedure:
hostAgentServiceConnectProcessHandler.ServeHTTP(w, r)
case HostAgentServiceGetTemplateSizeProcedure:
hostAgentServiceGetTemplateSizeHandler.ServeHTTP(w, r)
default:
http.NotFound(w, r)
}
@ -1000,3 +1033,7 @@ func (UnimplementedHostAgentServiceHandler) KillProcess(context.Context, *connec
func (UnimplementedHostAgentServiceHandler) ConnectProcess(context.Context, *connect.Request[gen.ConnectProcessRequest], *connect.ServerStream[gen.ConnectProcessResponse]) error {
return connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.ConnectProcess is not implemented"))
}
func (UnimplementedHostAgentServiceHandler) GetTemplateSize(context.Context, *connect.Request[gen.GetTemplateSizeRequest]) (*connect.Response[gen.GetTemplateSizeResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("hostagent.v1.HostAgentService.GetTemplateSize is not implemented"))
}

View File

@ -104,6 +104,11 @@ service HostAgentService {
// ConnectProcess re-attaches to a running process and streams its output.
rpc ConnectProcess(ConnectProcessRequest) returns (stream ConnectProcessResponse);
// GetTemplateSize returns the actual disk usage of a template's rootfs file.
// Used by the control plane to populate size_bytes for templates that have
// size 0 in the database (e.g. system base templates seeded before the
// rootfs was built).
rpc GetTemplateSize(GetTemplateSizeRequest) returns (GetTemplateSizeResponse);
}
message CreateSandboxRequest {
@ -123,8 +128,7 @@ message CreateSandboxRequest {
// inactivity. 0 means no auto-pause.
int32 timeout_sec = 4;
// Disk size in MB for the rootfs. Base images are expanded to this size
// at host agent startup. Default: 5120 (5 GB).
// Deprecated: disk size is now determined by the host agent.
int32 disk_size_mb = 6;
// Team UUID that owns the template (hex string). All-zeros = platform.
@ -146,8 +150,12 @@ message CreateSandboxResponse {
string host_ip = 3;
// Runtime metadata collected during sandbox creation (e.g. envd_version,
// kernel_version, firecracker_version, agent_version).
// kernel_version, vmm_version, agent_version).
map<string, string> metadata = 4;
// Actual disk size in MB allocated for the sandbox rootfs.
// Determined by the host agent (max of requested size and origin rootfs size).
int32 disk_size_mb = 5;
}
message DestroySandboxRequest {
@ -192,7 +200,8 @@ message ResumeSandboxResponse {
message CreateSnapshotRequest {
string sandbox_id = 1;
// Deprecated: use team_id + template_id instead.
// Human-readable template name, recorded into the snapshot's
// wrenn-snapshot.json metadata.
string name = 2;
// Team UUID that will own the new template.
string team_id = 3;
@ -222,6 +231,10 @@ message ExecRequest {
repeated string args = 3;
// Timeout for the command in seconds (default: 30).
int32 timeout_sec = 4;
// Environment variables to set for the command.
map<string, string> envs = 5;
// Working directory for the command.
string cwd = 6;
}
message ExecResponse {
@ -438,6 +451,19 @@ message FlattenRootfsResponse {
int64 size_bytes = 1;
}
message GetTemplateSizeRequest {
// Team UUID that owns the template (hex string). All-zeros = platform.
string team_id = 1;
// Template UUID (hex string).
string template_id = 2;
}
message GetTemplateSizeResponse {
// Actual disk usage of the template rootfs in bytes. Uses block-level
// accounting so sparse files report only allocated blocks.
int64 size_bytes = 1;
}
// ── PTY ─────────────────────────────────────────────────────────────
message PtyAttachRequest {