buildbarn / bb-deployments

Example deployments of Buildbarn on various platforms
Apache License 2.0
102 stars 70 forks source link

Buildbarn allows action to modify input files #86

Closed ssingularity closed 3 months ago

ssingularity commented 1 year ago

Behavior

Buildbarn allows action to modify input files, however bazel local build does't allow the action to do this.

Specific Scene

here is an easy action which modifies input files

def _convert_to_uppercase_impl(ctx):
    in_file = ctx.file.input
    out_file = ctx.actions.declare_file("hello_world")
    ctx.actions.run_shell(
        outputs = [out_file],
        inputs = [in_file],
        arguments = [in_file.path, out_file.path],
        command = "echo \"command exit not normally\" > $1 && cat $1 >> $2",
    )
    return [DefaultInfo(files = depset([out_file]))]

bazel build local result:

: shell_command/foo.txt: Read-only file system

bazel build remote with buildbarn successfully

Probable Reason

I guess maybe I use the root as the runner image's user causes the behavior? But the example in the bb-deployment also uses the root as the runner image's user.

Caused Bug

The behavior results in the bug that, when someone modifies his own 0 byte intput file, other people's 0 byte input file is also affeted and causes the build fail and hard to reproduce the problem, because the 0 byte input files are all hard-linked to same file

EdSchouten commented 1 year ago

I guess maybe I use the root as the runner image's user causes the behavior? But the example in the bb-deployment also uses the root as the runner image's user.

Yes, this is exactly it. You're supposed to run bb_worker as user root in one container, and bb_runner as some non-root user. That way the build actions are not able to modify input files.

Moving this to bb-deployments, as it's not a bug on the bb-remote-execution side.

ssingularity commented 1 year ago

Thanks! I will update the bb_runner image for using non-root user in my bb cluster to fix the bug caused by it.