Skip to content

Commit

Permalink
Don't depend on firecracker in darwin builds (#790)
Browse files Browse the repository at this point in the history
* Don't depend on firecracker in darwin builds

* Make gazelle happy
  • Loading branch information
siggisim authored and tylerwilliams committed Jul 28, 2021
1 parent d85aa1d commit 5166973
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 21 deletions.
54 changes: 33 additions & 21 deletions enterprise/server/remote_execution/containers/firecracker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// +build linux
// +build !android

package firecracker

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -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.")
}

0 comments on commit 5166973

Please sign in to comment.