Skip to content

Commit

Permalink
firecracker: ensure runfiles lib is used (#6190)
Browse files Browse the repository at this point in the history
  • Loading branch information
sluongng committed Mar 19, 2024
1 parent 5cefd30 commit b0a4a2f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ go_library(
target_compatible_with = [
"@platforms//os:linux",
],
x_defs = {
"initrdRunfilePath": "$(rlocationpath //enterprise/vmsupport/bin:initrd.cpio)",
"vmlinuxRunfilePath": "$(rlocationpath //enterprise/vmsupport/bin:vmlinux)",
},
deps = [
"//enterprise/server/remote_execution/commandutil",
"//enterprise/server/remote_execution/container",
Expand Down Expand Up @@ -60,6 +64,7 @@ go_library(
"@com_github_klauspost_cpuid//:cpuid",
"@com_github_prometheus_client_golang//prometheus",
"@com_github_sirupsen_logrus//:logrus",
"@io_bazel_rules_go//go/runfiles:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_sync//errgroup",
"@org_golang_x_sys//unix",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
_ "embed"

"github.com/armon/circbuf"
"github.com/bazelbuild/rules_go/go/runfiles"
"github.com/buildbuddy-io/buildbuddy/enterprise/server/remote_execution/commandutil"
"github.com/buildbuddy-io/buildbuddy/enterprise/server/remote_execution/container"
"github.com/buildbuddy-io/buildbuddy/enterprise/server/remote_execution/containers/docker"
Expand Down Expand Up @@ -347,6 +348,12 @@ type ExecutorConfig struct {
GuestAPIVersion string
}

var (
// set by x_defs in BUILD file
initrdRunfilePath string
vmlinuxRunfilePath string
)

// GetExecutorConfig computes the ExecutorConfig for this executor instance.
//
// WARNING: The given buildRootDir will be used as the jailer root dir. Because
Expand All @@ -356,11 +363,19 @@ type ExecutorConfig struct {
// everything after "/tmp" is 65 characters, so 38 are left for the jailerRoot.
func GetExecutorConfig(ctx context.Context, buildRootDir string) (*ExecutorConfig, error) {
bundle := vmsupport_bundle.Get()
initrdPath, err := putFileIntoDir(ctx, bundle, "enterprise/vmsupport/bin/initrd.cpio", buildRootDir, 0755)
initrdRunfileLocation, err := runfiles.Rlocation(initrdRunfilePath)
if err != nil {
return nil, err
}
initrdPath, err := putFileIntoDir(ctx, bundle, initrdRunfileLocation, buildRootDir, 0755)
if err != nil {
return nil, err
}
vmlinuxRunfileLocation, err := runfiles.Rlocation(vmlinuxRunfilePath)
if err != nil {
return nil, err
}
kernelPath, err := putFileIntoDir(ctx, bundle, "enterprise/vmsupport/bin/vmlinux", buildRootDir, 0755)
kernelPath, err := putFileIntoDir(ctx, bundle, vmlinuxRunfileLocation, buildRootDir, 0755)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b0a4a2f

Please sign in to comment.