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

systemd: use bootconfig for unified cgroup hierarchy #3886

Merged

Conversation

bcressey
Copy link
Contributor

@bcressey bcressey commented Apr 10, 2024

Issue number:
Related: #3883

Description of changes:
This takes advantage of the new Twoliter support for bootconfig drop-ins and variant metadata.

Variants with the unified-cgroup-hierarchy feature flag set will end up installing the new subpackage when the image is built, which will populate the default bootconfig with the right systemd option.

Default to "hybrid" at build time rather than "unified" since the two variants that don't support boot config (aws-ecs-1 and aws-ecs-1-nvidia) also require "hybrid" mode.

Testing done:
When building aws-dev, the following capability is logged for the metadata rpm:

  #13 0.582 bottlerocket-image-feature(unified-cgroup-hierarchy)

Later, this triggers the expected installation of the new subpackage:

  #15 1.175 Installing dependencies:
...
  #15 1.175  bottlerocket-systemd                          aarch64 252.22-1      repo 4.4 M
  #15 1.175  bottlerocket-systemd-console                  aarch64 252.22-1      repo  49 k
  #15 1.175  bottlerocket-systemd-networkd                 aarch64 252.22-1      repo 1.6 M
  #15 1.175  bottlerocket-systemd-resolved                 aarch64 252.22-1      repo 416 k
  #15 1.175  bottlerocket-systemd-unified-cgroup-hierarchy aarch64 252.22-1      repo 7.2 k

After boot, the expected hierarchy and settings are present:

bash-5.2# df /sys/fs/cgroup
Filesystem     1K-blocks  Used Available Use% Mounted on
cgroup2                0     0         0    - /sys/fs/cgroup

bash-5.2# apiclient get settings.boot.init
{
  "settings": {
    "boot": {
      "init": {
        "systemd.unified_cgroup_hierarchy": [
          "1"
        ]
      }
    }
  }
}

I also verified I could override the setting and the system would come up in hybrid mode.

For a variant like aws-k8s-1.24, the hybrid subpackage is installed and the system comes up in hybrid mode as expected.

  #15 1.191 Installing dependencies:
...
  #15 1.191  bottlerocket-systemd                         aarch64 252.22-1       repo 4.4 M
  #15 1.191  bottlerocket-systemd-hybrid-cgroup-hierarchy aarch64 252.22-1       repo 6.6 k

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

packages/systemd/systemd.spec Outdated Show resolved Hide resolved
@bcressey
Copy link
Contributor Author

⬆️ force push removes the use of Supplements and weak dependencies. It's not quite as elegant but will avoid the risk of subtle failures.

Instead of changing the way that systemd is compiled based on the
image feature flag, the expected init parameter can be added to a
bootconfig drop-in.

The systemd package now requires one of the cgroup hierarchy packages
when installing as part of a variant image build, so that the build
will fail if neither can be installed rather than falling back to the
default behavior.

If necessary, the cgroup hierarchy setting can still be overridden at
runtime or by replacing the default bootconfig file.

Signed-off-by: Ben Cressey <[email protected]>
@bcressey
Copy link
Contributor Author

⬆️ force push fixes parens

Copy link
Contributor

@yeazelm yeazelm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@bcressey bcressey merged commit c7df387 into bottlerocket-os:develop Apr 12, 2024
35 checks passed
@bcressey bcressey deleted the unified-cgroup-bootconfig branch April 12, 2024 00:16
@ginglis13 ginglis13 mentioned this pull request May 7, 2024
14 tasks
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.

3 participants