Update openvswitch to support cgroups v2

Adds check and if cgroups v2 is active use
cgroups v2 file structure for setting cpus

Change-Id: I603271a1b043d192988694c50ea7411a567b16ca
This commit is contained in:
SPEARS, DUSTIN (ds443n) 2023-10-30 16:24:41 -04:00
parent ff552d5969
commit b769895a60
3 changed files with 32 additions and 12 deletions

View File

@ -15,7 +15,7 @@ apiVersion: v1
appVersion: v1.0.0
description: OpenStack-Helm OpenVSwitch
name: openvswitch
version: 0.1.18
version: 0.1.19
home: http://openvswitch.org
icon: https://www.openstack.org/themes/openstack/images/project-mascots/Neutron/OpenStack_Project_Neutron_vertical.png
sources:

View File

@ -77,19 +77,38 @@ function start () {
# No need to create the cgroup if lcore_mask or pmd_cpu_mask is not set.
if [[ -n ${PMD_CPU_MASK} || -n ${LCORE_MASK} ]]; then
# Setup Cgroups to use when breaking out of Kubernetes defined groups
mkdir -p /sys/fs/cgroup/cpuset/osh-openvswitch
target_mems="/sys/fs/cgroup/cpuset/osh-openvswitch/cpuset.mems"
target_cpus="/sys/fs/cgroup/cpuset/osh-openvswitch/cpuset.cpus"
if [ "$(stat -fc %T /sys/fs/cgroup/)" = "cgroup2fs" ]; then
# Setup Cgroups to use when breaking out of Kubernetes defined groups
mkdir -p /sys/fs/cgroup/osh-openvswitch
target_mems="/sys/fs/cgroup/osh-openvswitch/cpuset.mems"
target_cpus="/sys/fs/cgroup/osh-openvswitch/cpuset.cpus"
touch $target_mems
touch $target_cpus
# Ensure the write target for the for cpuset.mem for the pod exists
if [[ -f "$target_mems" && -f "$target_cpus" ]]; then
# Write cpuset.mem and cpuset.cpus for new cgroup and add current task to new cgroup
cat /sys/fs/cgroup/cpuset/cpuset.mems > "$target_mems"
cat /sys/fs/cgroup/cpuset/cpuset.cpus > "$target_cpus"
echo $$ > /sys/fs/cgroup/cpuset/osh-openvswitch/tasks
# Ensure the write target for the for cpuset.mem for the pod exists
if [[ -f "$target_mems" && -f "$target_cpus" ]]; then
# Write cpuset.mem and cpuset.cpus for new cgroup and add current task to new cgroup
cat /sys/fs/cgroup/cpuset.mems.effective > "$target_mems"
cat /sys/fs/cgroup/cpuset.cpus.effective > "$target_cpus"
echo $$ > /sys/fs/cgroup/osh-openvswitch/cgroup.procs
else
echo "ERROR: Could not find write target for either cpuset.mems: $target_mems or cpuset.cpus: $target_cpus"
fi
else
echo "ERROR: Could not find write target for either cpuset.mems: $target_mems or cpuset.cpus: $target_cpus"
# Setup Cgroups to use when breaking out of Kubernetes defined groups
mkdir -p /sys/fs/cgroup/cpuset/osh-openvswitch
target_mems="/sys/fs/cgroup/cpuset/osh-openvswitch/cpuset.mems"
target_cpus="/sys/fs/cgroup/cpuset/osh-openvswitch/cpuset.cpus"
# Ensure the write target for the for cpuset.mem for the pod exists
if [[ -f "$target_mems" && -f "$target_cpus" ]]; then
# Write cpuset.mem and cpuset.cpus for new cgroup and add current task to new cgroup
cat /sys/fs/cgroup/cpuset/cpuset.mems > "$target_mems"
cat /sys/fs/cgroup/cpuset/cpuset.cpus > "$target_cpus"
echo $$ > /sys/fs/cgroup/cpuset/osh-openvswitch/tasks
else
echo "ERROR: Could not find write target for either cpuset.mems: $target_mems or cpuset.cpus: $target_cpus"
fi
fi
fi
{{- end }}

View File

@ -19,4 +19,5 @@ openvswitch:
- 0.1.16 Restore ServiceAccount to openvswitch pod
- 0.1.17 Add buffer to wait for potential new CTL file before running chown
- 0.1.18 Add value for extra poststart command
- 0.1.19 Add check for cgroups v2 file structure
...