Merge "ovs-dpdk: create separate cgroup for openvswitch-vswitchd pods"

This commit is contained in:
Zuul 2019-09-27 15:24:41 +00:00 committed by Gerrit Code Review
commit 496a512acc
2 changed files with 25 additions and 0 deletions

View File

@ -53,14 +53,34 @@ function start () {
{{- if .Values.conf.ovs_dpdk.pmd_cpu_mask }}
ovs-vsctl --db=unix:${OVS_SOCKET} --no-wait set Open_vSwitch . other_config:pmd-cpu-mask={{ .Values.conf.ovs_dpdk.pmd_cpu_mask | quote }}
PMD_CPU_MASK={{ .Values.conf.ovs_dpdk.pmd_cpu_mask | quote }}
{{- end }}
{{- if .Values.conf.ovs_dpdk.lcore_mask }}
ovs-vsctl --db=unix:${OVS_SOCKET} --no-wait set Open_vSwitch . other_config:dpdk-lcore-mask={{ .Values.conf.ovs_dpdk.lcore_mask | quote }}
LCORE_MASK={{ .Values.conf.ovs_dpdk.lcore_mask | quote }}
{{- end }}
ovs-vsctl --db=unix:${OVS_SOCKET} --no-wait set Open_vSwitch . other_config:vhost-sock-dir={{ .Values.conf.ovs_dpdk.vhostuser_socket_dir | quote }}
ovs-vsctl --db=unix:${OVS_SOCKET} --no-wait set Open_vSwitch . other_config:dpdk-init=true
# 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"
# 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
{{- end }}
exec /usr/sbin/ovs-vswitchd unix:${OVS_SOCKET} \

View File

@ -133,6 +133,8 @@ of hugepages must still be defined in the values.yaml.*/}}
mountPath: /dev
- name: pci-drivers
mountPath: /sys/bus/pci/drivers
- name: cgroup
mountPath: /sys/fs/cgroup
{{- end }}
volumes:
- name: pod-tmp
@ -178,5 +180,8 @@ of hugepages must still be defined in the values.yaml.*/}}
hostPath:
path: {{ .Values.conf.ovs_dpdk.hugepages_mountpath | quote }}
type: Directory
- name: cgroup
hostPath:
path: /sys/fs/cgroup
{{- end }}
{{- end }}