Skip to content

Commit

Permalink
Allow runners to mount special filesystem in the input root
Browse files Browse the repository at this point in the history
This introduces a new runner decorator that can create mounts in the
input root. This is useful for 'chroot' runners that have userland tools
that require '/proc' or '/sys', which are created by the operating
system. This is how to configure the runner:

  inputRootMounts: [{
    mountpoint: 'proc',
    source: '/proc',
    filesystemType: 'proc',
  }, {
    mountpoint: 'sys',
    source: '/sys',
    filesystemType: 'sysfs',
  }],
  • Loading branch information
stagnation committed Sep 13, 2023
1 parent 70efb72 commit 13e7f92
Show file tree
Hide file tree
Showing 8 changed files with 277 additions and 31 deletions.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Required for @com_google_absl and remoteapis that use it.
build --host_cxxopt=-std=c++17
run --workspace_status_command="bash tools/workspace-status.sh"
7 changes: 7 additions & 0 deletions cmd/bb_runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ func main() {
buildDirectoryPath,
commandCreator,
configuration.SetTmpdirEnvironmentVariable)
for _, mountinfo := range configuration.InputRootMounts {
r = runner.NewMountingRunner(
r,
buildDirectory,
mountinfo,
)
}

// Let bb_runner replace temporary directories with symbolic
// links pointing to the temporary directory set up by
Expand Down
2 changes: 1 addition & 1 deletion cmd/bb_scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func main() {
}
killOperationsAuthorizer, err := authorizerFactory.NewAuthorizerFromConfiguration(configuration.KillOperationsAuthorizer)
if err != nil {
return util.StatusWrap(err, "Failed to create kill operaitons authorizer")
return util.StatusWrap(err, "Failed to create kill operations authorizer")
}

platformQueueWithNoWorkersTimeout := configuration.PlatformQueueWithNoWorkersTimeout
Expand Down
18 changes: 18 additions & 0 deletions pkg/filesystem/lazy_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,21 @@ func (d *lazyDirectory) Apply(arg interface{}) error {
defer underlying.Close()
return underlying.Apply(arg)
}

func (d *lazyDirectory) Mount(mountpoint path.Component, source string, fstype string) error {
underlying, err := d.openUnderlying()
if err != nil {
return err
}
defer underlying.Close()
return underlying.Mount(mountpoint, source, fstype)
}

func (d *lazyDirectory) Unmount(mountpoint path.Component) error {
underlying, err := d.openUnderlying()
if err != nil {
return err
}
defer underlying.Close()
return underlying.Unmount(mountpoint)
}
158 changes: 128 additions & 30 deletions pkg/proto/configuration/bb_runner/bb_runner.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions pkg/proto/configuration/bb_runner/bb_runner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,23 @@ message ApplicationConfiguration {
// https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java
// https://www.smileykeith.com/2021/03/08/locking-xcode-in-bazel/
map<string, string> apple_xcode_developer_directories = 14;

// Mount special filesystems in the input root.
// This is useful when running with `chroot`.
// some tools require access to special filesystems
// that are created when the operating system boots.
// An input root with a full userland implementation may need these.
// Typical choices are:
// {"proc", "/proc", "proc"}
// {"sys", "/sys", "sysfs"}
repeated mount_info input_root_mounts = 15;
}

message mount_info {
// Mount a filesystem in the input root, a relative path.
string mountpoint = 1;
// Source filesystem from the runner's operating system, absolute path.
string source = 2;
// Type of filesystem, see `mount`'s man page.
string filesystem_type = 3;
}
2 changes: 2 additions & 0 deletions pkg/runner/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ go_library(
"local_runner_rss_kibibytes.go",
"local_runner_unix.go",
"local_runner_windows.go",
"mounting_runner.go",
"path_existence_checking_runner.go",
"temporary_directory_installing_runner.go",
"temporary_directory_symlinking_runner.go",
Expand All @@ -19,6 +20,7 @@ go_library(
visibility = ["//visibility:public"],
deps = [
"//pkg/cleaner",
"//pkg/proto/configuration/bb_runner",
"//pkg/proto/runner",
"//pkg/proto/tmp_installer",
"@com_github_buildbarn_bb_storage//pkg/filesystem",
Expand Down
Loading

0 comments on commit 13e7f92

Please sign in to comment.