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

manifest: zstd #1247

Merged
merged 5 commits into from
Feb 25, 2025
Merged

manifest: zstd #1247

merged 5 commits into from
Feb 25, 2025

Conversation

supakeen
Copy link
Member

@supakeen supakeen commented Feb 24, 2025

Implements the existing zstd stage from osbuild and creates the appropriate scaffolding to use it.

Also enables a new image type for Fedora Minimal that uses it 1.

@supakeen supakeen requested a review from a team as a code owner February 24, 2025 09:30
@supakeen supakeen force-pushed the zstd branch 2 times, most recently from 16bc74f to ae3730e Compare February 24, 2025 10:41
achilleas-k
achilleas-k previously approved these changes Feb 24, 2025
Copy link
Member

@achilleas-k achilleas-k left a comment

Choose a reason for hiding this comment

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

Neat!

@achilleas-k
Copy link
Member

Conflict :(

mvo5
mvo5 previously approved these changes Feb 24, 2025
Copy link
Contributor

@mvo5 mvo5 left a comment

Choose a reason for hiding this comment

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

This looks fine, some suggestions inline (could be followups but the duplication is something that might be worth doing now).

@@ -454,6 +454,36 @@ var (
basePartitionTables: minimalrawPartitionTables,
requiredPartitionSizes: requiredDirectorySizes,
}

minimalrawZstdImgType = imageType{
name: "minimal-raw-zst",
Copy link
Contributor

Choose a reason for hiding this comment

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

(wondering) should this be minimal-raw-zstd (notice the leading d) ? I know the extension if zst (which I personally find very confusing) so maybe fine? idk

Copy link
Member Author

Choose a reason for hiding this comment

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

I indeed picked it based on the extension so the image type is related to the output artifact, I did things in the same style in #1233.

},
defaultImageConfig: &distro.ImageConfig{
EnabledServices: minimalRawServices,
// NOTE: temporary workaround for a bug in initial-setup that
Copy link
Contributor

Choose a reason for hiding this comment

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

This duplicates a lot of the existing minimal-raw with only minimal changes - including this workaround which means we will (if we ever remove it) keep the two in sync. How about just making a "maker" function to keep them in sync automatically? Something like:

diff --git a/pkg/distro/fedora/distro.go b/pkg/distro/fedora/distro.go
index 5959db425..9921a24e4 100644
--- a/pkg/distro/fedora/distro.go
+++ b/pkg/distro/fedora/distro.go
@@ -424,42 +424,16 @@ var (
                exports:                []string{"container"},
                requiredPartitionSizes: requiredDirectorySizes,
        }
+       minimalrawImgType     = makeMinimalRaw("minimal-raw", "xz", "xz")
+       minimalrawZstdImgType = makeMinimalRaw("minimal-raw-zst", "zstd", "zst")
+)
 
-       minimalrawImgType = imageType{
-               name:        "minimal-raw",
-               filename:    "disk.raw.xz",
-               compression: "xz",
-               mimeType:    "application/xz",
-               packageSets: map[string]packageSetFunc{
-                       osPkgsKey: packageSetLoader,
-               },
-               defaultImageConfig: &distro.ImageConfig{
-                       EnabledServices: minimalRawServices,
-                       // NOTE: temporary workaround for a bug in initial-setup that
-                       // requires a kickstart file in the root directory.
-                       Files: []*fsnode.File{initialSetupKickstart()},
-                       Grub2Config: &osbuild.GRUB2Config{
-                               // Overwrite the default Grub2 timeout value.
-                               Timeout: 5,
-                       },
-               },
-               rpmOstree:              false,
-               kernelOptions:          defaultKernelOptions,
-               bootable:               true,
-               defaultSize:            2 * datasizes.GibiByte,
-               image:                  diskImage,
-               buildPipelines:         []string{"build"},
-               payloadPipelines:       []string{"os", "image", "xz"},
-               exports:                []string{"xz"},
-               basePartitionTables:    minimalrawPartitionTables,
-               requiredPartitionSizes: requiredDirectorySizes,
-       }
-
-       minimalrawZstdImgType = imageType{
-               name:        "minimal-raw-zst",
-               filename:    "disk.raw.zst",
-               compression: "zstd",
-               mimeType:    "application/zstd",
+func makeMinimalRaw(name, compression, ext string) imageType {
+       return imageType{
+               name:        name,
+               filename:    "disk.raw." + ext,
+               compression: compression,
+               mimeType:    "application/" + compression,
                packageSets: map[string]packageSetFunc{
                        osPkgsKey: packageSetLoader,
                },
@@ -479,12 +453,12 @@ var (
                defaultSize:            2 * datasizes.GibiByte,
                image:                  diskImage,
                buildPipelines:         []string{"build"},
-               payloadPipelines:       []string{"os", "image", "zstd"},
-               exports:                []string{"zstd"},
+               payloadPipelines:       []string{"os", "image", compression},
+               exports:                []string{compression},
                basePartitionTables:    minimalrawPartitionTables,
                requiredPartitionSizes: requiredDirectorySizes,
        }
-)
+}
 
 type distribution struct {
        name               string

Copy link
Member Author

Choose a reason for hiding this comment

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

This sort of thing keeps popping up and we do it in various ways (we also just 'copy' image types and then adjust some of their properties in the newDistro function as well so the above would introduce a '3rd way'.

I don't particularly care which way we pick; do you want me to do your suggestion or the newDistro way?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, yeah, the newDistro() way seems fine then.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a commit to do this.

supakeen and others added 5 commits February 24, 2025 14:19
There's a `zstd` stage in `osbuild` which was never plumbed through.
This copies over the `xz` stage and adjusts the name.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This copies over the `xz` manifest to add a `zstd` one.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
Adds a new image type [1] that is equal to the `minimal-raw` image type for
Fedora Minimal; however it uses `zstd` compression which is much faster
to compress thus speeding up the build.

[1]: fedora-minimal/distribution-minimal#12

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
A small test that ensures some bits are in zstd manifest.

Co-authored-by: Michael Vogt <michael.vogt@gmail.com>
Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
Instead of duplication let's copy the minimal raw image type and change
some of its properties inside `newDistro`.

Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
@supakeen
Copy link
Member Author

Rebased, resolved conflicts, addressed comments.

Copy link
Member

@ondrejbudai ondrejbudai left a comment

Choose a reason for hiding this comment

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

Awesome, thanks! :) I still think that the final compression should be just configurable per build (with a sane default per image type), but this is a step in the correct direction.

How would you feel about adding a minimal-raw-zstd alias for minimal-raw-zst? I think it may remove some friction...

@@ -726,6 +696,14 @@ func newDistro(version int) distro.Distro {
}
vhdImgType.defaultImageConfig = vhdConfig.InheritFrom(qcow2ImgType.defaultImageConfig)

minimalrawZstdImgType := minimalrawImgType
Copy link
Member

Choose a reason for hiding this comment

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

It's interesting that the image type name is "minimal-raw-zst", but the variable name is "minimalRawZstdImgType". My gut feeling is that the d shouldn't be there.

@ondrejbudai ondrejbudai added this pull request to the merge queue Feb 25, 2025
Merged via the queue into osbuild:main with commit c771d2d Feb 25, 2025
18 checks passed
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.

4 participants