Skip to content

Commit

Permalink
Add coreos-keep-cgroup-v1.service
Browse files Browse the repository at this point in the history
In f31, the default cgroup changed to v2. However, we've decided to stay
on v1 for the time being. Thus, we don't want older nodes upgrading to
f31 to be forced into v2.

Add a tiny service which just scans the BLS configs and injects the
`systemd.unified_cgroup_hierarchy` karg as needed.

For more information, see:
coreos/fedora-coreos-tracker#292
coreos/fedora-coreos-streams#26 (comment)
  • Loading branch information
jlebon committed Nov 26, 2019
1 parent 6bd4b0d commit 235b0f2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ enable afterburn-firstboot-checkin.service
enable afterburn-sshkeys@.service
# Update agent
enable zincati.service
enable coreos-keep-cgroup-v1.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=CoreOS Keep CGroups v1
Documentation=https://github.com/coreos/fedora-coreos-tracker/issues/292
RequiresMountsFor=/boot
# Note we don't conditionalize on ConditionKernelCommandLine= here because the
# kernel arg might've been added manually just for this boot; we still want to
# change the BLS entries in that case.

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/coreos-keep-cgroup-v1

[Install]
WantedBy=multi-user.target
17 changes: 17 additions & 0 deletions overlay.d/90cgroups/usr/libexec/coreos-keep-cgroup-v1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -euo pipefail

for f in /boot/loader/entries/*.conf; do
options=$(grep '^options ' "$f" | cut -f2- -d' ')

# If it's already specified, don't touch whatever value is there. That way,
# users that purposely opted into v2 early keep it. It also makes this
# script idempotent.
if grep -q "systemd.unified_cgroup_hierarchy" <<< "$options"; then
continue
fi

# otherwise, make sure we stay on v1
sed -e "/^options / s/$/ systemd.unified_cgroup_hierarchy=0/" -i "$f"
echo "$(basename "$f"): injected systemd.unified_cgroup_hierarchy=0"
done

0 comments on commit 235b0f2

Please sign in to comment.