This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 181
Cannot set up private network with LXC >= 3.1.0 #484
Labels
Comments
same here, happens to me also. Is there any fix for this issue? |
Here's the patch for lxc >= 4.0.2
|
Here's the patch for lxc >= 4.0.2 that should be able to support both cgroups-v1 and cgroups-v2. It was tested on vagrant 2.2.14 + lxc 4.0.6... and seems to work. Note: according to kernel documentation, the "tasks" file was removed in cgroup-v2, thus we have to use the diff --git a/scripts/pipework b/scripts/pipework
index 2438ca9..04bbd4b 100755
--- a/scripts/pipework
+++ b/scripts/pipework
@@ -144,9 +144,12 @@ CONTAINER_IFNAME=${CONTAINER_IFNAME:-eth1}
# Second step: find the guest (for now, we only support LXC containers)
while read _ mnt fstype options _; do
- [ "$fstype" != "cgroup" ] && continue
- echo "$options" | grep -qw devices || continue
+ [ "$fstype" != "cgroup2" ] && [ "$fstype" != "cgroup" ] && continue
+ if [ "$fstype" = "cgroup" ]; then
+ echo "$options" | grep -qw devices || continue
+ fi
CGROUPMNT=$mnt
+ CGROUPTYPE=$fstype
done < /proc/mounts
[ "$CGROUPMNT" ] || {
@@ -154,7 +157,9 @@ done < /proc/mounts
}
# Try to find a cgroup matching exactly the provided name.
-N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l)
+[ "$CGROUPTYPE" = "cgroup" ] && N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l)
+[ "$CGROUPTYPE" = "cgroup2" ] && N=$(find "$CGROUPMNT" -name "lxc.payload.$GUESTNAME" | wc -l)
+
case "$N" in
0)
# If we didn't find anything, try to lookup the container with Docker.
@@ -235,7 +240,8 @@ fi
if [ "$DOCKERPID" ]; then
NSPID=$DOCKERPID
else
- NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks")
+ NSPATH=$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)
+ [ -f "$NSPATH/tasks" ] && NSPID=$(head -n 1 "$NSPATH/tasks")
[ "$NSPID" ] || {
# it is an alternative way to get the pid
NSPID=$(lxc-info -n "$GUESTNAME" | grep PID | grep -Eo '[0-9]+') |
Hey, sorry for the silence here but this project is looking for maintainers 😅 As per #499, I've added the |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm on Arch Linux and I'm trying to set up a Vagrant box with a private network. This, however, fails when I try to
vagrant up
. I've done some digging, and thepipework
script popped up. Most notably, this check preventsvagrant up
from setting up the private network. On systems with LXC >= 3.1.0, this check yields2
.As per lxc/lxc#2782, I understood that there has been a split in information storage since LXC 3.1.0. I could resolve my own issues by writing this patch:
I intentionally did not send in a PR because I'm certain this patch will break the
vagrant-lxc
plugin for systems using LXC < 3.1.0.Debug info
The text was updated successfully, but these errors were encountered: