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

Prefer bubblewrap for network isolation #473

Closed
wants to merge 1 commit into from

Conversation

tiran
Copy link
Collaborator

@tiran tiran commented Oct 10, 2024

Bubblewrap is another tool for unsharing namespaces. It sets up a network namespace with a disconnected loopback.

Fixes: #472

@mergify mergify bot added the ci label Oct 10, 2024
Copy link
Member

@dhellmann dhellmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks OK for now. We should consider if this should be configurable by the user somehow, but this at least lets us move forward.

Edit: nvm. I tested it and it seems to work -- see comments below about adding --privileged to docker and fixing the --unshare-net option.

@prarit
Copy link
Contributor

prarit commented Oct 10, 2024

Let's try this and see if it works better. OOC do you test if it solved the MPI issue in a container?

Bubblewrap is another tool for unsharing namespaces. It sets up a
network namespace with a disconnected loopback.

Fixes: python-wheel-build#472
Signed-off-by: Christian Heimes <[email protected]>
@tiran
Copy link
Collaborator Author

tiran commented Oct 10, 2024

Let's try this and see if it works better. OOC do you test if it solved the MPI issue in a container?

$ bwrap --unshare-net --dev-bind / / -- /usr/lib64/openmpi/bin/mpicc -showme:compile
-I/usr/include/openmpi-x86_64

$ unshare -rn -- /usr/lib64/openmpi/bin/mpicc -showme:compile
[hostname:1498104] opal_ifinit: unable to find network interfaces.
-I/usr/include/openmpi-x86_64

if sys.platform == "linux":
NETWORK_ISOLATION = ["unshare", "--net", "--map-current-user"]
NETWORK_ISOLATION = [
["bwrap", "--unshare-network", "--dev-bind", "/", "/", "--"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--unshare-network doesn't appear to be valid? Is this supposed to be --unshare-net ?

Copy link
Contributor

@prarit prarit Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: this needs docker to specify --privileged in builder's bin/boostrap.sh o/w you get an error

bwrap: Creating new namespace failed: Operation not permitted

@tiran tiran marked this pull request as draft October 11, 2024 14:36
@tiran
Copy link
Collaborator Author

tiran commented Oct 15, 2024

bwrap does not work for us. It requires additional permissions and adjustments to work in an unprivileged container. We want a system that works in podman out of the box and in docker with minimal adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use bubblewrap (bwrap) instead of unshare for network isolation
3 participants