Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1866794

Summary: enforce-node-allocatable with system-reserved cannot be applied with default installation
Product: OpenShift Container Platform Reporter: Frederic Giloux <fgiloux>
Component: NodeAssignee: Harshal Patil <harpatil>
Node sub component: Kubelet QA Contact: MinLi <minmli>
Status: CLOSED WONTFIX Docs Contact:
Severity: high    
Priority: medium CC: aos-bugs, dhellmann, fdeutsch, harpatil, jokerman, nagrawal, rphillips, tsweeney
Version: 3.11.0   
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-06-08 11:03:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Frederic Giloux 2020-08-06 11:39:34 UTC
Description of problem:
In clusters with big nodes (96 hyperthreaded cores for instance) it is required to use enforce-node-allocatable with system-reserved to prevent the kubelet, container runtime and other system processes to get starved of CPU cycles.

Setting enforce-node-allocatable in the node configMap does not work out of the box. In my experiment it required the following things:

- The creation of missing slices:
/sys/fs/cgroup/cpuset/system.slice
/sys/fs/cgroup/freezer/system.slice
/sys/fs/cgroup/hugetlb/system.slice
/sys/fs/cgroup/net_cls/system.slice
/sys/fs/cgroup/net_prio/system.slice
/sys/fs/cgroup/perf_event/system.slice
/sys/fs/cgroup/pids/system.slice

- The use of cgroupfs instead of systemd as cgroup driver.

Version-Release number of selected component (if applicable):
Tested with 3.11 and RHEL 7.8 but I believe that this may be similar with 4.x

How reproducible:
Always

Steps to Reproduce:
1a. Try to configure enforce-node-allocatable in the node configMap with system-reserved, for instance:
kubeletArguments:
      cgroups-per-qos:
      - "true"
      enforce-node-allocatable:
      - "pods"
      - "system-reserved"
      cgroup-root:
      - '/'
      system-reserved-cgroup:
      - '/system.slice'
      system-cgroups:
      - '/system.slice'
      system-reserved:
      - 'cpu=500m,memory=1Gi'
=> does not work

1b. Similar with also kube-reserved and an additional slice so that more cpu.shares can be allocated to it
kubeletArguments:
      cgroups-per-qos:
      - "true"
      enforce-node-allocatable:
      - "pods"
      - "system-reserved"
      - "kube-reserved"
      cgroup-root:
      - '/'
      cgroup-driver:
      - 'cgroupfs'
      system-reserved-cgroup:
      - '/system.slice'
      kube-reserved-cgroup:
      - '/podruntime.slice'
      system-cgroups:
      - '/system.slice'
      kube-reserved:
      - 'cpu=500m,memory=1Gi'
      system-reserved:
      - 'cpu=500m,memory=1Gi'

2. Modify the node service unit:
$ cat /etc/systemd/system/atomic-openshift-node.service
[Unit]
Description=OpenShift Node
After=docker.service
After=chronyd.service
After=ntpd.service
Wants=docker.service
Documentation=https://github.com/openshift/origin
Wants=dnsmasq.service
After=dnsmasq.service
Requires=system.slice
After=system.slice
Requires=docker.service
After=docker.slice
After=slices.target

[Service]
Slice=podruntime.slice
Type=notify
EnvironmentFile=/etc/sysconfig/atomic-openshift-node
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/cpuset/podruntime.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/freezer/podruntime.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/hugetlb/podruntime.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/net_cls/podruntime.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/net_prio/podruntime.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/perf_event/podruntime.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/pids/podruntime.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/cpuset/system.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/freezer/system.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/hugetlb/system.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/net_cls/system.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/net_prio/system.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/perf_event/system.slice
ExecStartPre=/usr/bin/mkdir -p /sys/fs/cgroup/pids/system.slice
ExecStartPre=/usr/bin/sleep 30s
ExecStart=/usr/local/bin/openshift-node
LimitNOFILE=65536
LimitCORE=infinity
WorkingDirectory=/var/lib/origin/
SyslogIdentifier=atomic-openshift-node
Restart=always
RestartSec=5s
TimeoutStartSec=300
OOMScoreAdjust=-999

[Install]
WantedBy=multi-user.target

3. Create a new slice
$ cat /usr/lib/systemd/system/podruntime.slice
[Unit]
Description=Limited resources slice for Kubernetes services
Documentation=man:systemd.special(7)
DefaultDependencies=no
Before=slices.target
Requires=-.slice
After=-.slice

4. Modifiy the docker service to use cgroupfs
$ cat /lib/systemd/system/docker.service
    --exec-opt native.cgroupdriver=cgroupfs \

5. Reload daemons and restart services

=> works

Actual results:
Kubelet does not start.

Expected results:
Kubelet starts and the cgroups configuration is applied

Additional info:

- system.slice cannot be modified.
- I may be missing something in terms of dependencies but I needed to introduce a 30s delay in the atomic-openshift-node unit to get it consistently working by reboot.
- Without enforce-node-allocatable with system-reserved the cgroups settings are as follows when 4 CPU cores are system-reserved for a 96 cores node:
kubepods slice gets (96-4) * 1024 = 92160
system.slice 1024
user.slice 1024
this means that under contention system.slice gets effectively 1.04 cores.

Comment 2 Seth Jennings 2020-08-07 21:33:34 UTC
This is not a supported configuration.  We only support cgroup-driver=systemd.  We do not support creating a separate slice for the kubelet and container runtime and, thus, kube-reserved has no use (or no addition use beyond system-reserved).

This is a supported configuration

      cgroups-per-qos:
      - "true"
      enforce-node-allocatable:
      - "pods"
      cgroup-driver:
      - "systemd"
      system-reserved:
      - "cpu=500m,memory=1Gi"

If they find the system-reservation is insufficient to maintain node stability, they should increase it as needed.  This may be required for very large nodes like the one mentioned.

Comment 3 Frederic Giloux 2020-08-08 04:55:27 UTC
>>>> We only support cgroup-driver=systemd.  We do not support creating a separate slice for the kubelet and container runtime and, thus, kube-reserved has no use (or no addition use beyond system-reserved).
Thanks for the clarification. I will look at creating a doc bug:
https://docs.openshift.com/container-platform/3.11/admin_guide/allocating_node_resources.html#allocating-node-settings

Next points

- Is system-reserved under enforce-node-allocatable supported? I did not get it working with /system.slice. 
      enforce-node-allocatable:
      - "pods"
      - "system-reserved"

- If yes I did not get it working with /system.slice. Is it supported to specify another slice?
      system-reserved-cgroup:
      - '/another-system.slice'

- With a node with 96 cores we have seen through production metrics and load tests that 4 cores need to be reserved for kubelet, container runtime, etc.
Considering the configuration you propose, without having system-reserved under enforce-node-allocatable:
      cgroups-per-qos:
      - "true"
      enforce-node-allocatable:
      - "pods"
      cgroup-driver:
      - "systemd"
      system-reserved:
      - "cpu=4"
we have the following at the system level for cpu.shares:
kubepods slice gets (96-4) * 1024 = 92160
system.slice 1024
user.slice 1024
this means that under contention system.slice gets effectively 1.04 cores (1024÷94208×96)

To have effectively 4 cores under contention we need
      cgroups-per-qos:
      - "true"
      enforce-node-allocatable:
      - "pods"
      cgroup-driver:
      - "systemd"
      system-reserved:
      - "cpu=73"
which gives at the system level:
kubepods slice gets (96-73) * 1024 = 23552
system.slice 1024
user.slice 1024
This however means that out of 96 cores, 73 won't be able to be requested by pods as they will be subtracted from what is allocatable by the node. This is obviously not what we desire.

Comment 4 Frederic Giloux 2020-08-10 08:13:38 UTC
Doc bugzilla for kube-reserved already existed: bug 1853249
Creaded bugzilla for cgroup-driver: bug 1867502

Comment 5 Seth Jennings 2020-08-10 14:23:48 UTC
- Is system-reserved under enforce-node-allocatable supported? I did not get it working with /system.slice. 

No.  Only "pods" is really supported.  No other configuration is tested for OCP.

I think this is an issue though.  Found this upstream and I think I'm going to reopen it.
https://github.com/kubernetes/kubernetes/issues/72881

I think that it makes sense to set cpu.shares on system.slice (or system-reserved-cgroup flag if overridden) based on system-reserved, even if enforce-node-allocatable doesn't include enforcement for system-reserved.

Comment 6 Seth Jennings 2020-08-10 14:28:26 UTC
I reopened the upstream issue
https://github.com/kubernetes/kubernetes/issues/72881#issuecomment-671389165

Comment 7 Frederic Giloux 2020-08-10 15:00:25 UTC
Thanks for clarifying that system-reserved is not supported under enforce-node-allocatable. I have opened a doc bugzilla for it: Bug 1867706 
I am looking forward to getting this progressed upstream, more over that I did not manage to modify /system.slice and am curious about it. Thanks for looking after that.