Skip to content

Commit

Permalink
more robustly identify current cgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
BenTheElder committed Feb 25, 2021
1 parent 3660e47 commit d777456
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions images/base/files/usr/local/bin/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,17 @@ fix_cgroup() {
fi
echo 'INFO: detected cgroup v1'
echo 'INFO: fix cgroup mounts for all subsystems'
# see: https://d2iq.com/blog/running-kind-inside-a-kubernetes-cluster-for-continuous-integration
# capture initial state before modifying
# See: https://d2iq.com/blog/running-kind-inside-a-kubernetes-cluster-for-continuous-integration
# Capture initial state before modifying
#
# Basically we're looking for the cgroup-path for the cpu controller for the
# current process. this tells us what cgroup-path the container is in.
# Then we collect the subsystems that are active on this path.
# We assume the cpu controller is in use on all node containers.
#
# See: https://man7.org/linux/man-pages/man7/cgroups.7.html
local current_cgroup
current_cgroup=$(grep systemd /proc/self/cgroup | cut -d: -f3)
current_cgroup=$(grep -E '^[^:]*:([^:]*,)?cpu(,[^,:]*)?:.*' /proc/self/cgroup | cut -d: -f3)
local cgroup_subsystems
cgroup_subsystems=$(findmnt -lun -o source,target -t cgroup | grep "${current_cgroup}" | awk '{print $2}')
# For each cgroup subsystem, Docker does a bind mount from the current
Expand Down

0 comments on commit d777456

Please sign in to comment.