Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container_image file not found when used in genrule #26

Open
aymanrady opened this issue Aug 26, 2018 · 1 comment
Open

container_image file not found when used in genrule #26

aymanrady opened this issue Aug 26, 2018 · 1 comment
Assignees

Comments

@aymanrady
Copy link

Description of the problem / feature request:

Not sure if this issue belongs here or not.
Depending on a container_image in a genrule tools errors when sandboxfs is used

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "io_bazel_rules_docker",
    # HEAD at 2018/08/26
    urls = ["https://github.com/bazelbuild/rules_docker/archive/d6046608f4979ad891a8c0574dd07ca7bf5f870e.tar.gz"],
    sha256 = "6872b8b0b509c6c3fcc3876f9b009b1984d9c5de80f9234dd6bfb8d8c504f314",
    strip_prefix = "rules_docker-d6046608f4979ad891a8c0574dd07ca7bf5f870e",
)

load("@io_bazel_rules_docker//container:container.bzl", container_repositories = "repositories")
container_repositories()

BUILD.bazel

load("@io_bazel_rules_docker//container:container.bzl", "container_image")

container_image(
    name = "image"
)

genrule(
    name = "use-tool",
    tools = [":image"],
    outs = ["out.txt"],
    # works when run standalone
    # local = True,
    cmd = "cat $(location :image) > $@",
)

bazel build --sandbox_debug --verbose_failures //:use-tool

Loading: 
Loading: 0 packages loaded
INFO: Analysed target //:use-tool (0 packages loaded).
INFO: Found 1 target...
[0 / 2] [-----] BazelWorkspaceStatusAction stable-status.txt
ERROR: /home/aymanrady/dev/sandbox/bazel-docker-py/BUILD.bazel:7:1: Executing genrule //:use-tool failed (Exit 1): linux-sandbox failed: error executing command 
  (cd /home/aymanrady/.cache/bazel/_bazel_aymanrady/3e53b67470e506c3592f875ac1f72484/execroot/__main__ && \
  exec env - \
    PATH=/home/aymanrady/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
    TMPDIR=/tmp \
  /home/aymanrady/.cache/bazel/_bazel_aymanrady/3e53b67470e506c3592f875ac1f72484/execroot/__main__/_bin/linux-sandbox -t 15 -w /home/aymanrady/.cache/bazel/_bazel_aymanrady/3e53b67470e506c3592f875ac1f72484/sandbox/linux-sandbox/1/execroot/__main__ -w /tmp -w /dev/shm -D -- /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; cat bazel-out/host/bin/image > bazel-out/k8-fastbuild/genfiles/out.txt')
src/main/tools/linux-sandbox.cc:154: linux-sandbox-pid1 has PID 6230
src/main/tools/linux-sandbox-pid1.cc:175: working dir: /home/aymanrady/.cache/bazel/_bazel_aymanrady/3e53b67470e506c3592f875ac1f72484/sandbox/linux-sandbox/1/execroot/__main__
src/main/tools/linux-sandbox-pid1.cc:194: writable: /home/aymanrady/.cache/bazel/_bazel_aymanrady/3e53b67470e506c3592f875ac1f72484/sandbox/linux-sandbox/1/execroot/__main__
src/main/tools/linux-sandbox-pid1.cc:194: writable: /tmp
src/main/tools/linux-sandbox-pid1.cc:194: writable: /dev/shm
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev/pts
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /dev/shm
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev/mqueue
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /dev/hugepages
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/lock
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/rpc_pipefs
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/cgmanager/fs
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/user/1000
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/user/1000/gvfs
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/snapd/ns
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /run/docker/netns/default
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/kernel/security
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/systemd
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/cpuset
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/net_cls,net_prio
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/memory
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/freezer
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/blkio
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/devices
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/hugetlb
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/perf_event
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/cpu,cpuacct
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/rdma
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/cgroup/pids
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/pstore
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/kernel/debug
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/kernel/config
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /sys/fs/fuse/connections
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /proc
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /proc/sys/fs/binfmt_misc
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /proc/sys/fs/binfmt_misc
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /proc/fs/nfsd
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/vlc/190
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/ubuntu-make/471
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/spotify/19
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/tldr/162
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/jq/6
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/core/5145
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/ubuntu-make/479
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/vlc/365
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/core/4917
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/ubuntu-make/492
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/http/21
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/vlc/158
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /snap/core/4830
src/main/tools/linux-sandbox-pid1.cc:265: remount ro: /home
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /home/aymanrady/.cache/bazel/_bazel_aymanrady/3e53b67470e506c3592f875ac1f72484/sandbox/linux-sandbox/1/execroot/__main__
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /home/aymanrady/.cache/bazel/_bazel_aymanrady/3e53b67470e506c3592f875ac1f72484/sandbox/linux-sandbox/1/execroot/__main__
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /tmp
src/main/tools/linux-sandbox-pid1.cc:265: remount rw: /dev/shm
src/main/tools/process-tools.cc:118: sigaction(32, &sa, nullptr) failed
src/main/tools/process-tools.cc:118: sigaction(33, &sa, nullptr) failed
cat: bazel-out/host/bin/image: No such file or directory
src/main/tools/linux-sandbox-pid1.cc:437: waitpid returned 2
src/main/tools/linux-sandbox-pid1.cc:457: child exited with code 1
src/main/tools/linux-sandbox.cc:204: child exited normally with exitcode 1
Target //:use-tool failed to build
INFO: Elapsed time: 0.385s, Critical Path: 0.09s
INFO: 0 processes.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully

Any other information, logs, or outputs that you want to share?

Bazel 0.16.1
sandboxfs 625ac9a

@jmmv
Copy link
Contributor

jmmv commented Sep 3, 2018

Hey, this caught my attention because I saw sandboxfs mentioned as the cause behind this issue... but neither your bazel build invocation nor the logs have any mentions of sandboxfs. Are you really using sandboxfs (and have confirmed that this problem happens exclusively when sandboxfs is on), or is this "just" a generic sandboxing issue?

@jmmv jmmv self-assigned this Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants