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

add and remove image features #318

Merged
merged 4 commits into from
Jul 2, 2024

Conversation

bcressey
Copy link
Contributor

Issue number:
N/A

Description of changes:
Remove support for the unified-cgroup-hierarchy image feature, which is effectively no longer implemented.

Add support for two new features that are enabled by default:

  • in-place-updates, which affects the partition layout
  • host-containers, which only affects what software might be installed

These features can be targeted by RPM boolean dependencies in package specs to arrange for software to be installed only if the feature is enabled for a given variant.

Most of the non-boilerplate work was in partyplanner. get_partition_sizes needed better handling for the RESERVED partitions (rather than assuming there would always be two), and set_partition_sizes needed a new mode for laying out partitions.

Testing done:
Built aws-dev with both new features disabled, and aws-k8s-1.24 with both enabled.

aws-dev partition layout:

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048           10239   4.0 MiB     EF02  BIOS-BOOT
   2           10240           30719   10.0 MiB    EF00  EFI-SYSTEM
   3           30720          194559   80.0 MiB    FFFF  BOTTLEROCKET-BOOT-A
   4          194560         3962879   1.8 GiB     FFFF  BOTTLEROCKET-ROOT-A
   5         3962880         4003839   20.0 MiB    FFFF  BOTTLEROCKET-HASH-A
   6         4003840         4106239   50.0 MiB    FFFF  BOTTLEROCKET-RESERV...
   7         4106240         4190207   41.0 MiB    FFFF  BOTTLEROCKET-PRIVATE
   8         4190208         4192255   1024.0 KiB  FFFF

aws-k8s-1.24 partition layout:

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048           10239   4.0 MiB     EF02  BIOS-BOOT
   2           10240           20479   5.0 MiB     EF00  EFI-SYSTEM
   3           20480          102399   40.0 MiB    FFFF  BOTTLEROCKET-BOOT-A
   4          102400         1986559   920.0 MiB   FFFF  BOTTLEROCKET-ROOT-A
   5         1986560         2007039   10.0 MiB    FFFF  BOTTLEROCKET-HASH-A
   6         2007040         2058239   25.0 MiB    FFFF  BOTTLEROCKET-RESERV...
   7         2058240         2068479   5.0 MiB     FFFF  EFI-BACKUP
   8         2068480         2150399   40.0 MiB    FFFF  BOTTLEROCKET-BOOT-B
   9         2150400         4034559   920.0 MiB   FFFF  BOTTLEROCKET-ROOT-B
  10         4034560         4055039   10.0 MiB    FFFF  BOTTLEROCKET-HASH-B
  11         4055040         4106239   25.0 MiB    FFFF  BOTTLEROCKET-RESERV...
  12         4106240         4190207   41.0 MiB    FFFF  BOTTLEROCKET-PRIVATE
  13         4190208         4192255   1024.0 KiB  FFFF

cargo make repack-variant worked for both.

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.

The cgroup v2 feature was used to conditionally compile systemd and
select the default cgroup hierarchy - either "hybrid" or "unified" -
at build time.

Packages no longer have access to conditional compilation assisted by
the build tool, so this feature flag is obsolete. Instead, the cgroup
hierarchy can be selected through kernel command line parameters in
the variant definition.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Promote "in-place-updates" and "host-containers" to feature flags,
and enable them by default for backwards compatibility.

The in-place update feature requires two sets of partitions, which
wastes disk space if the variant will only ever run on nodes that are
replaced rather than updated in-place.

The host containers feature supports execution of containers at fixed
points during the host's lifecycle: during boot, and as background
services once the host is fully configured. This may not be desirable
for variants looking for stronger guarantees that only the software
included in the immutable root filesystem will ever run.

Expose these as feature flags so that variants can opt-out.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
`buildsys` no longer sets this feature flag for any build, so do not
look for it during bcond generation or apply it to the metadata RPM.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
Add the "in-place-updates" and "host-containers" features to the
metadata spec so that packages can arrange to be installed based on
whether they are enabled or disabled.

Disabling in-place update support implies removing the second set of
partitions that will never be used. Adjust the partition sizing logic
to double the size of the first set of partitions when the second set
is omitted.

Overhaul the "get_partition_sizes" logic in partyplanner to avoid
making assumptions about the partition layout of input images, such
as how many there will be, and instead to just record details about
each partition.

Signed-off-by: Ben Cressey <bcressey@amazon.com>
twoliter/embedded/rpm2img Show resolved Hide resolved
pp_offset["BOOT-${bank}"]="${offset}"
pp_size["BOOT-${bank}"]="${boot_mib}"
((offset += boot_mib))
pp_offset["BOOT-${bank}"]="${offset}"
Copy link
Contributor

Choose a reason for hiding this comment

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

This spacing seem suspicious, are they spaces or tabs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This spacing seem suspicious, are they spaces or tabs?

There are no tabs in this file. It's just following the two space indentation convention of the rest of the file.

twoliter/embedded/rpm2img Show resolved Hide resolved
twoliter/embedded/partyplanner Show resolved Hide resolved
@bcressey bcressey merged commit 8a29af7 into bottlerocket-os:develop Jul 2, 2024
1 check passed
@bcressey bcressey deleted the more-image-features branch July 2, 2024 23:09
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