Skip to content

Commit

Permalink
Reproduce the /proc error in chroot runners.
Browse files Browse the repository at this point in the history
This works fine for regular runners that uses the docker image
user-space. But the next commit enables chroot runners and it starts to
fail.

bazel build \
    --remote_executor=grpc://localhost:8980 \
    --remote_instance_name=fuse \
    --remote_default_exec_properties OSFamily=linux \
    --remote_default_exec_properties container-image="docker://ghcr.io/catthehacker/ubuntu:act-22.04@sha256:5f9c35c25db1d51a8ddaae5c0ba8d3c163c5e9a4a6cc97acd409ac7eae239448" \
    @//:introspection

This is step one of three to verify the solution to:
buildbarn/bb-remote-execution#115
  • Loading branch information
stagnation committed Mar 27, 2024
1 parent bd5c7fe commit 4bd72af
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 1 deletion.
24 changes: 23 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
load("@aspect_bazel_lib//lib:run_binary.bzl", "run_binary")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")

# gazelle:prefix github.com/buildbarn/bb-deployments
# gazelle:exclude dummy_for_dependencies.go
gazelle(
name = "gazelle",
)

# $ bazel build //cmd/ls-proc
# $ cp -f bazel-bin/cmd/ls-proc/ls-proc_/ls-proc ls-proc
run_binary(
name = "introspection",
outs = ["out"],
args = ["$(location out)"],
execution_requirements = {
"no-cache": "1",
},
tool = ":ls-proc",
srcs = [
# env is required in path resolution for chroot actions.
"usr/bin/env",
# Not strictly needed, but symmetric with sys and proc.
"dev/dummy",
# Send a directory for /sys and /proc
# Bazel wants a file for it to send the directory.
"sys/dummy",
"proc/dummy",
],
)
15 changes: 15 additions & 0 deletions cmd/ls-proc/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "github.com/buildbarn/bb-deployments/cmd/ls-proc",
visibility = ["//visibility:private"],
)

go_binary(
name = "ls-proc",
embed = [":go_default_library"],
visibility = ["//visibility:public"],
pure = "on",
)
27 changes: 27 additions & 0 deletions cmd/ls-proc/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package main

import (
"fmt"
"os"
"log"
)

func main() {
entries, err := os.ReadDir("/proc/self")
if err != nil {
log.Fatal("Reading /proc/self:", err)
}
if len(os.Args) == 1 {
log.Fatal("Usage: ls-proc <output file>")
}

max := 10
for i, e := range entries {
if i > max {
break
}
fmt.Println(e.Name())
}

os.Create(os.Args[1])
}
Empty file added dev/dummy
Empty file.
Binary file added ls-proc
Binary file not shown.
Empty file added proc/dummy
Empty file.
Empty file added sys/dummy
Empty file.
Binary file added usr/bin/env
Binary file not shown.

0 comments on commit 4bd72af

Please sign in to comment.