From 98b3984ec7048ce48dce9905485093be28993928 Mon Sep 17 00:00:00 2001 From: Pete Birley Date: Thu, 16 Aug 2018 11:11:09 -0500 Subject: [PATCH] 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 --- libvirt/templates/bin/_libvirt.sh.tpl | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/libvirt/templates/bin/_libvirt.sh.tpl b/libvirt/templates/bin/_libvirt.sh.tpl index 5a5e38dd..7d2c5b61 100644 --- a/libvirt/templates/bin/_libvirt.sh.tpl +++ b/libvirt/templates/bin/_libvirt.sh.tpl @@ -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:]')"