Libvirt: Warn if hugetlb cgroup controller is enabled

This PS adds a warning if the hugetlb cgroup controller is enabled
as it prevents restarts of the libvirt pod without shutting down
kvm vms. The controller can be disabled by passing
`cgroup_disable=hugetlb` to the kernel params.

Change-Id: Idd26fd3c19191f3c3e0aeb6fa3efa9a4ec48ee54
Signed-off-by: Pete Birley <pete@port.direct>
This commit is contained in:
Pete Birley 2018-08-16 11:11:09 -05:00
parent da01b0c09c
commit 98b3984ec7
1 changed files with 16 additions and 10 deletions

View File

@ -54,17 +54,23 @@ if [ 0"$hp_count" -gt 0 ]; then
# Kubernetes 1.10.x introduced cgroup changes that caused the container's
# hugepage byte limit quota to zero out. This workaround sets that pod limit
# back to the total number of hugepage bytes available to the baremetal host.
if [ -d /sys/fs/cgroup/hugetlb ]; then
# NOTE(portdirect): Kubelet will always create pod specific cgroups for
# hugetables so if the hugetlb cgroup is enabled, when k8s removes the pod
# it will also remove the hugetlb cgroup for the pod, taking any qemu
# processes with it.
echo "WARN: As the hugetlb cgroup is enabled, it will not be possible to restart the libvirt pod via k8s, without killing VMs."
for limit in $(ls /sys/fs/cgroup/hugetlb/kubepods/hugetlb.*.limit_in_bytes); do
target="/sys/fs/cgroup/hugetlb/$(dirname $(awk -F: '($2~/hugetlb/){print $3}' /proc/self/cgroup))/$(basename $limit)"
# Ensure the write target for the hugepage limit for the pod exists
if [ ! -f "$target" ]; then
echo "ERROR: Could not find write target for hugepage limit: $target"
fi
for limit in $(ls /sys/fs/cgroup/hugetlb/kubepods/hugetlb.*.limit_in_bytes); do
target="/sys/fs/cgroup/hugetlb/$(dirname $(awk -F: '($2~/hugetlb/){print $3}' /proc/self/cgroup))/$(basename $limit)"
# Ensure the write target for the hugepage limit for the pod exists
if [ ! -f "$target" ]; then
echo "ERROR: Could not find write target for hugepage limit: $target"
fi
# Write hugetable limit for pod
echo "$(cat $limit)" > "$target"
done
# Write hugetable limit for pod
echo "$(cat $limit)" > "$target"
done
fi
# Determine OS default hugepage size to use for the hugepage write test
default_hp_kb="$(cat /proc/meminfo | grep Hugepagesize | tr -cd '[:digit:]')"