diff --git a/enterprise/server/remote_execution/containers/firecracker/BUILD b/enterprise/server/remote_execution/containers/firecracker/BUILD index 1cce31e333d..fb5fc0b732f 100644 --- a/enterprise/server/remote_execution/containers/firecracker/BUILD +++ b/enterprise/server/remote_execution/containers/firecracker/BUILD @@ -2,33 +2,45 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( name = "firecracker", - srcs = ["firecracker.go"], + srcs = [ + "firecracker.go", + "firecracker_darwin.go", + ], data = [ "//enterprise/vmsupport/bin:initrd.cpio", "//enterprise/vmsupport/bin:vmlinux", ], importpath = "github.com/buildbuddy-io/buildbuddy/enterprise/server/remote_execution/containers/firecracker", visibility = ["//visibility:public"], - deps = [ - "//enterprise:bundle", - "//enterprise/server/remote_execution/commandutil", - "//enterprise/server/remote_execution/container", - "//enterprise/server/util/ext4", - "//enterprise/server/util/networking", - "//enterprise/server/util/vsock", - "//proto:remote_execution_go_proto", - "//proto:vmexec_go_proto", - "//server/interfaces", - "//server/util/disk", - "//server/util/log", - "//server/util/status", - "@com_github_firecracker_microvm_firecracker_go_sdk//:firecracker-go-sdk", - "@com_github_firecracker_microvm_firecracker_go_sdk//client/models", - "@com_github_google_uuid//:uuid", - "@com_github_sirupsen_logrus//:logrus", - "@io_bazel_rules_go//go/tools/bazel:go_default_library", - "@org_golang_x_sys//unix", - ], + deps = select({ + "@io_bazel_rules_go//go/platform:darwin": [ + "//enterprise/server/remote_execution/container", + "//proto:remote_execution_go_proto", + "//server/interfaces", + "//server/util/status", + ], + "@io_bazel_rules_go//go/platform:linux": [ + "//enterprise:bundle", + "//enterprise/server/remote_execution/commandutil", + "//enterprise/server/remote_execution/container", + "//enterprise/server/util/ext4", + "//enterprise/server/util/networking", + "//enterprise/server/util/vsock", + "//proto:remote_execution_go_proto", + "//proto:vmexec_go_proto", + "//server/interfaces", + "//server/util/disk", + "//server/util/log", + "//server/util/status", + "@com_github_firecracker_microvm_firecracker_go_sdk//:firecracker-go-sdk", + "@com_github_firecracker_microvm_firecracker_go_sdk//client/models", + "@com_github_google_uuid//:uuid", + "@com_github_sirupsen_logrus//:logrus", + "@io_bazel_rules_go//go/tools/bazel:go_default_library", + "@org_golang_x_sys//unix", + ], + "//conditions:default": [], + }), ) go_test( diff --git a/enterprise/server/remote_execution/containers/firecracker/firecracker.go b/enterprise/server/remote_execution/containers/firecracker/firecracker.go index cff240144b3..7fdd35834ae 100644 --- a/enterprise/server/remote_execution/containers/firecracker/firecracker.go +++ b/enterprise/server/remote_execution/containers/firecracker/firecracker.go @@ -1,3 +1,6 @@ +// +build linux +// +build !android + package firecracker import ( diff --git a/enterprise/server/remote_execution/containers/firecracker/firecracker_darwin.go b/enterprise/server/remote_execution/containers/firecracker/firecracker_darwin.go new file mode 100644 index 00000000000..ab7600a64e1 --- /dev/null +++ b/enterprise/server/remote_execution/containers/firecracker/firecracker_darwin.go @@ -0,0 +1,88 @@ +// +build darwin +// +build !ios + +package firecracker + +import ( + "context" + "io" + + "github.com/buildbuddy-io/buildbuddy/enterprise/server/remote_execution/container" + "github.com/buildbuddy-io/buildbuddy/server/interfaces" + "github.com/buildbuddy-io/buildbuddy/server/util/status" + + repb "github.com/buildbuddy-io/buildbuddy/proto/remote_execution" +) + +type ContainerOpts struct { + // The OCI container image. ex "alpine:latest" + ContainerImage string + + // The action directory with inputs / outputs + ActionWorkingDirectory string + + // The number of CPUs to allocate to this VM. + NumCPUs int64 + + // The amount of RAM, in MB, to allocate to this VM. + MemSizeMB int64 + + // Whether or not to enable networking. + EnableNetworking bool + + // Optional flags -- these will default to sane values. + // They are here primarily for debugging and running + // VMs outside of the normal action-execution framework. + + // DebugMode runs init in debugmode and enables stdin/stdout so + // that machines can be logged into via the console. + DebugMode bool + + // ForceVMIdx forces a machine to use a particular vm index, + // allowing for multiple locally-started VMs to avoid using + // conflicting network interfaces. + ForceVMIdx int +} + +type firecrackerContainer struct{} + +func NewContainer(ctx context.Context, opts interface{}) (*firecrackerContainer, error) { + c := &firecrackerContainer{} + return c, nil +} + +func (c *firecrackerContainer) Run(ctx context.Context, command *repb.Command, actionWorkingDir string) *interfaces.CommandResult { + return &interfaces.CommandResult{} +} + +func (c *firecrackerContainer) Create(ctx context.Context, actionWorkingDir string) error { + return status.UnimplementedError("Not yet implemented.") +} + +func (c *firecrackerContainer) Exec(ctx context.Context, cmd *repb.Command, stdin io.Reader, stdout io.Writer) *interfaces.CommandResult { + return &interfaces.CommandResult{} +} + +func (c *firecrackerContainer) PullImageIfNecessary(ctx context.Context) error { + return status.UnimplementedError("Not yet implemented.") +} + +func (c *firecrackerContainer) Remove(ctx context.Context) error { + return status.UnimplementedError("Not yet implemented.") +} + +func (c *firecrackerContainer) Pause(ctx context.Context) error { + return status.UnimplementedError("Not yet implemented.") +} + +func (c *firecrackerContainer) Unpause(ctx context.Context) error { + return status.UnimplementedError("Not yet implemented.") +} + +func (c *firecrackerContainer) Wait(ctx context.Context) error { + return status.UnimplementedError("Not yet implemented.") +} + +func (c *firecrackerContainer) Stats(ctx context.Context) (*container.Stats, error) { + return nil, status.UnimplementedError("Not yet implemented.") +}