Skip to content

Commit 07c8496

Browse files
committed
update
Signed-off-by: dongjiang <[email protected]>
1 parent 71af88a commit 07c8496

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

hack/script/container_remount_lxcfs.sh

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,22 @@ for container in $containers;do
1212
if [ "$mountpoint" = "$LXCFS_ROOT_PATH" ];then
1313
echo "remount $container"
1414
PID=$(docker inspect --format '{{.State.Pid}}' $container)
15-
# mount /proc
16-
for file in meminfo cpuinfo loadavg stat diskstats swaps uptime;do
17-
echo nsenter --target $PID --mount -- mount -B "$LXCFS/proc/$file" "/proc/$file"
18-
nsenter --target $PID --mount -- mount -B "$LXCFS/proc/$file" "/proc/$file"
19-
done
20-
# mount /sys
21-
for file in online;do
22-
echo nsenter --target $PID --mount -- mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
23-
nsenter --target $PID --mount -- mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
24-
done
25-
fi
15+
if nsenter --target $PID --mount -- -- which mount >/dev/null 2>&1; then
16+
# mount /proc
17+
for file in meminfo cpuinfo loadavg stat diskstats swaps uptime;do
18+
echo nsenter --target $PID --mount -- mount -o bind "$LXCFS/proc/$file" "/proc/$file"
19+
nsenter --target $PID --mount -- mount -o bind "$LXCFS/proc/$file" "/proc/$file"
20+
done
21+
# mount /sys
22+
for file in online;do
23+
echo nsenter --target $PID --mount -- mount -o bind "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
24+
nsenter --target $PID --mount -- mount -o bind "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
25+
done
26+
else
27+
echo "容器 $container 没有 mount 软件"
28+
fi
29+
else
30+
echo "容器 $container 没有挂载 /var/lib/lxc/lxcfs"
31+
fi
2632
done
2733
exit 0

hack/script/container_remount_lxcfs_containerd.sh

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,21 @@ for container in $containers; do
1515
if [ "$count" != "0" ]; then
1616
echo "remount $container"
1717
PID=$(crictl inspect --output go-template --template '{{- .info.pid -}}' $container)
18-
# mount /proc
19-
for file in meminfo cpuinfo loadavg stat diskstats swaps uptime; do
20-
echo nsenter --target $PID --mount -- mount -B "$LXCFS/proc/$file" "/proc/$file"
21-
nsenter --target $PID --mount -- mount -B "$LXCFS/proc/$file" "/proc/$file"
22-
done
18+
if nsenter --target $PID --mount -- -- which mount >/dev/null 2>&1; then
19+
# mount /proc
20+
for file in meminfo cpuinfo loadavg stat diskstats swaps uptime; do
21+
echo nsenter --target $PID --mount -- mount -o bind "$LXCFS/proc/$file" "/proc/$file"
22+
nsenter --target $PID --mount -- mount -o bind "$LXCFS/proc/$file" "/proc/$file"
23+
done
2324

24-
# mount /sys
25-
for file in online; do
26-
echo nsenter --target $PID --mount -- mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
27-
nsenter --target $PID --mount -- mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
28-
done
25+
# mount /sys
26+
for file in online; do
27+
echo nsenter --target $PID --mount -- mount -o bind "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
28+
nsenter --target $PID --mount -- mount -o bind "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file"
29+
done
30+
else
31+
echo "容器 $container 没有 mount 软件"
32+
fi
2933
else
3034
echo "容器 $container 没有挂载 /var/lib/lxc/lxcfs"
3135
fi

0 commit comments

Comments
 (0)