Closed AuditeMarlow closed 1 year ago
same here, happens to me also. Is there any fix for this issue?
Here's the patch for lxc >= 4.0.2
--- pipework 2019-10-10 14:08:16.545642357 +0200
+++ pipework.patched 2020-06-30 14:08:22.309010624 +0200
@@ -154,7 +154,7 @@
}
# Try to find a cgroup matching exactly the provided name.
-N=$(find "$CGROUPMNT" -name "$GUESTNAME" | wc -l)
+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.
@@ -237,7 +237,7 @@
if [ "$DOCKERPID" ]; then
NSPID=$DOCKERPID
else
- NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "$GUESTNAME" | head -n 1)/tasks")
+ NSPID=$(head -n 1 "$(find "$CGROUPMNT" -name "lxc.payload.$GUESTNAME" | head -n 1)/tasks")
[ "$NSPID" ] || {
# it is an alternative way to get the pid
NSPID=$(lxc-info -n "$GUESTNAME" | grep PID | grep -Eo '[0-9]+')
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 lxc-info
fallback to get the pid.
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 :sweat_smile:
As per https://github.com/fgrehm/vagrant-lxc/issues/499, I've added the ignored
label and will close this issue. Thanks for the interest in the project and LMK if you want to step up and take ownership of this project on that other issue :wave:
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 https://github.com/lxc/lxc/issues/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