Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support flag file to runtime switch to cgroupv1 #35

Merged
merged 2 commits into from
Mar 1, 2022

Conversation

jepio
Copy link
Member

@jepio jepio commented Feb 7, 2022

support flag file to runtime switch to cgroupv1

The idea is to detect the presence of a flag file (/etc/flatcar-cgroupv1), to call systemctl switch-root with init.wrapper as an argument. init.wrapper takes care of unmounting the currently mounted cgroup after initramfs, allowing sysroot systemd to remount cgroupv1.

The detection is done at the end of initrd-parse-etc.service, and the parameters are passed to initrd-switch-root.service through a temporary environment file.

How to use

To be used with flatcar/init#62.

Testing done

  • Changelog entries added in the respective changelog/ directory (user-facing change, bug fix, security fix, update)

@jepio jepio force-pushed the jepio/runtime-revert-to-cgroupv1 branch 2 times, most recently from abff4a8 to 4182225 Compare February 21, 2022 12:12
@jepio jepio changed the title Jepio/runtime revert to cgroupv1 support flag file to runtime switch to cgroupv1 Feb 22, 2022
@jepio jepio marked this pull request as ready for review February 22, 2022 17:21
Pass a custom init commands (init.wrapper) to 'systemctl switch-root'
when leaving the initramfs. This init.wrapper is responsible for
disabling all cgroup controllers and unmounting cgroup2, and injecting
(by means of a bind mount) custom kernel arguments so that sysroot
systemd sets up cgroupv1. We're adding this so that Flatcar users don't
have to reboot to switch back to cgroupv1, which is disruptive in many
deployments.

The usage of init.wrapper is conditional on two things:
* initramfs used up cgroupv2.
* user opted into to this behavior by creating the
  `/etc/flatcar-cgroupv1` flag file

There is a reason to not go through init.wrapper unconditionally, and
decide whether to take action-or-not there. When systemd runs in sysroot
and initramfs, it serializes some data structures and passes them from
the initramfs to allow some introspection. I believe this is primarily
systemd-analyze timing information. This doesn't work when we inject a
custom init between sysroot and initramfs (init.wrapper), so ensure we
only use the custom init when we really need to.

This is accomplished by passing the init.wrapper path through an INIT
environment variable, which is only defined when '/etc/flatcar-cgroupv1'
exists in the sysroot. An alternative would have been to conditionally
symlink the override snippet, which would get applied in the 'systemctl
daemon-reload' in 'initrd-parse-etc.service'. Neither option is
particularly obvious, but this one seems slightly easier to follow.
…fault

Moving controllers between cgroup v1 and v2 is difficult once they have been
used. So create a system.conf.d snippet that sets the Default*Accounting=no so
that moving controllers becomes possible.
@jepio jepio merged commit d586e78 into flatcar-master Mar 1, 2022
@jepio jepio deleted the jepio/runtime-revert-to-cgroupv1 branch March 1, 2022 08:05
jepio added a commit to flatcar-archive/coreos-overlay that referenced this pull request Mar 1, 2022
…ange

This pulls in flatcar/bootengine#35 and
flatcar/init#62, which enable boot time switching
back to legacy cgroups by creating a flag files (/etc/flatcar-cgroupv1) from
ignition.
jepio added a commit to flatcar-archive/coreos-overlay that referenced this pull request Mar 1, 2022
…ange

This pulls in flatcar/bootengine#35 and
flatcar/init#62, which enable boot time switching
back to legacy cgroups by creating a flag files (/etc/flatcar-cgroupv1) from
ignition.
jepio added a commit to flatcar-archive/coreos-overlay that referenced this pull request Mar 1, 2022
…ange

This pulls in flatcar/bootengine#35 and
flatcar/init#62, which enable boot time switching
back to legacy cgroups by creating a flag files (/etc/flatcar-cgroupv1) from
ignition.
jepio added a commit that referenced this pull request Mar 17, 2022
support flag file to runtime switch to cgroupv1
jepio added a commit to flatcar-archive/coreos-overlay that referenced this pull request Mar 17, 2022
…ange

This pulls in flatcar/bootengine#35 and
flatcar/init#62, which enable boot time switching
back to legacy cgroups by creating a flag files (/etc/flatcar-cgroupv1) from
ignition.

Also contains the subsequent bugfix to coreos-init:
c21ee83 "coreos-base/coreos-init: move processes to root cgroup before unbinding controllers"
t-lo pushed a commit to flatcar/scripts that referenced this pull request Apr 13, 2023
…ange

This pulls in flatcar/bootengine#35 and
flatcar/init#62, which enable boot time switching
back to legacy cgroups by creating a flag files (/etc/flatcar-cgroupv1) from
ignition.

Also contains the subsequent bugfix to coreos-init:
c21ee83df0a2302c0b7cfa375a5f191c14800ec8 "coreos-base/coreos-init: move processes to root cgroup before unbinding controllers"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants