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

Minimal image builds #182

Merged
merged 13 commits into from
Oct 3, 2023
Merged

Minimal image builds #182

merged 13 commits into from
Oct 3, 2023

Conversation

achilleas-k
Copy link
Member

@achilleas-k achilleas-k commented Sep 29, 2023

This PR adds a new feature to the build configuration called minimal which affects payload packages in two ways:

  • It ignores any statically defined packages for an image type (the packages defined on ImageType.packageSets).
  • It disables weak dependencies for all payload packages.

The option therefore creates a minimal image where the packages installed are only the ones required to boot the image and provide basic functionality according to Platform (for firmware and bootloader configuration for example) and the Environment (cloud-init for cloud environment for example), removing any packages from an image type that are added purely by policy.

For the qcow2 (and its derivatives), the enabled services have been removed from the base image type configuration and moved to the respective environments: EC2 (ami), Azure (vhd), and KVM (new env for qcow2).


THIS IS AN EXPERIMENTAL FEATURE

I don't intend for this to be exposed in osbuild-composer just yet. It's currently enabled only in Fedora. I tested locally a minimal build of Fedora 38 x86_64 qcow2 and it works. It shrinks the image from 500 MiB to 300 MiB, and reduces the package count from 453 to 215.

I'd like to get this in even if untested to have it as a proof of concept.
I intend for this to address a very common feature request which is the removal of base packages from image types. Instead of allowing package exclusion, a minimal image with weak dependencies disabled should allow users to add just the packages they want while the platform and environment define the packages they need. This will become even more powerful when we let users define the platform and environment directly. If (when) we introduce a null environment, and make it user-configurable, a user would be able to build a minimal qcow2 (as enabled in this PR) and also remove cloud-init, which is defined in the new KVM environment.

We don't do blueprint versioning in images.  This is an osbuild-composer
blueprint feature and it's all defined in that project.
Minimal will be used to create a minimal version of an image.

Add Minimal to utility command blueprints in cmd to enable the direct
conversion.
New environment, KVM, is meant for guest virtualisation (qcow2).
Return all the cloud-init related service names to enable for EC2.
Add the cloud-init package and services to the Azure environment, now
that the explicit services on the qcow2 (and its derivatives) have been
removed.
Add the KVM environment to the qcow2 struct and remove the explicit
services.
Support specifying the InstallWeakDeps option through the DiskImage
ImageKind, so that distros creating an image of that type can control
the weak dependency selection.

The option is a pointer to a boolean so that the nil value can fall back
to the default internal value defined by the pipeline (which can vary).
Don't send just the customizations but instead pass in the whole
Blueprint to the image functions.

This change is made only on Fedora for now to enable the 'minimal'
feature, which is considered experimental.
If a build request sets the 'minimal' option, disable weak dependencies
for the whole payload pipeline.
@supakeen
Copy link
Member

On first sight this is a great addition to the possibilities and will make any future Fedora editions-as-blueprints likely much easier as we can always start from a 'minimal' image type variant.

What I dislike is that this expands the combinations matrix we already have for our images with another dimension. I'm going to generate a few manifests and see what comes out of that because I feel that some image types with minimal turned on might produce the same manifest with perhaps only a different output format.

I'll go over it :)

@achilleas-k
Copy link
Member Author

I'm going to generate a few manifests and see what comes out of that because I feel that some image types with minimal turned on might produce the same manifest with perhaps only a different output format.

I'd be curious to see how many of them boot. We're pretty good with the definitions in Fedora I think, maybe not for IoT, but RHEL package sets are still not properly segmented so removing the static sets will likely make them unbootable.

Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

Overall, nice work and interesting experimental feature. 🚀 I added few comments, but nothing serious.

internal/environment/ec2.go Show resolved Hide resolved
pkg/distro/fedora/distro.go Show resolved Hide resolved
internal/environment/azure.go Show resolved Hide resolved
Copy link
Member

@thozza thozza left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@supakeen supakeen left a comment

Choose a reason for hiding this comment

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

I'm happy to approve this; it's a good lead-in to splitting out stuff in the image definitions later on.

@supakeen supakeen added this pull request to the merge queue Oct 3, 2023
Merged via the queue into osbuild:main with commit 8e95d86 Oct 3, 2023
7 checks passed
@achilleas-k achilleas-k deleted the the-minimal branch October 4, 2023 12:14
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