bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.31k stars 4.09k forks source link

linux-sandbox didn't remount sys, leads /sys/class/net not sync with network namespace #23273

Open comicfans opened 3 months ago

comicfans commented 3 months ago

Description of the bug:

when using linux-sandbox, it didn't remount /sys, leave /sys/class/net still being host network devices, not ones inside the network namespace. remount /sys (similar to /proc) resolve it. I have a branch https://github.com/comicfans/bazel/commit/891b41a2ef4106ae44caead07a95632925e67468 to address it, shall I create PR for this?

Which category does this issue belong to?

Local Execution

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

run command

linux-sandbox -N -R -- /bin/bash
ip link show
ls /sys/class/net
ip tuntap add tun0 mode tun
ip link show
ls /sys/class/net

ip link show will output correct devices in network namespace, but ls command will show host network devices

Which operating system are you running Bazel on?

linux

What is the output of bazel info release?

I'm testing on master dacb794

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

add test (without requires-network tag, then linux-sandbox will create network namespace for it) and ls /sys/class/net in test

What's the output of git remote get-url origin; git rev-parse HEAD ?

https://github.com/bazelbuild/bazel.git
3a1e9b83f8a31d0cea308966f493e50ea643ad00

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

https://stackoverflow.com/questions/15626088/tap-interfaces-and-dev-net-tun-device-using-ip-tuntap-command

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

No response

tjgq commented 3 months ago

Your changes look reasonable to me (other than the comment I made there). Can you please open a PR to run our test suite against it? If everything looks good, I'm happy to approve it.

tjgq commented 3 months ago

(Nevermind the bit about the comment.)

comicfans commented 3 months ago

Your changes look reasonable to me (other than the comment I made there). Can you please open a PR to run our test suite against it? If everything looks good, I'm happy to approve it.

PR created https://github.com/bazelbuild/bazel/pull/23274