Skip to content

many: HMS-10300 prepare splitting of imagetypes.yaml#2257

Open
avitova wants to merge 5 commits intoosbuild:mainfrom
avitova:split-imgtypes
Open

many: HMS-10300 prepare splitting of imagetypes.yaml#2257
avitova wants to merge 5 commits intoosbuild:mainfrom
avitova:split-imgtypes

Conversation

@avitova
Copy link
Contributor

@avitova avitova commented Mar 9, 2026

This PR contains changes in the functional part of the code, there is also a draft #2266 that shows what these changes allow us. We wanted to keep changes in the .yaml separately in order to prevent merge conflicts. :)

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.

Thank you this is already shaping up to be quite nice. I've put some comments in the files. Let me know what you think, some of them are pretty straightforward left-overs and some of them are maybe up for discussion (e.g. the double-loop).

I'd really prefer to drop the idea of any image config key existing within a file containing image types so if we can I think we should.

I'll check out your branch when I find some time to play around with how I'd do that/figure out the approach that makes sense to me 🙂.

@supakeen supakeen self-requested a review March 10, 2026 15:31
@avitova
Copy link
Contributor Author

avitova commented Mar 12, 2026

There's workstation-live-installer, pxe-tar-xz and bootc-rpm-installer. We can put those in a separate file as well, and that should make it! I assume we cannot really deduplicate, since cross-file anchor sharing is not possible. I moved image_config to distro definitions.

@avitova avitova changed the title multiple: HMS-10300 split imagetypes.yaml many: HMS-10300 split imagetypes.yaml Mar 13, 2026
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.

Starting to look great functionally; can you please drop the commits that actually do the YAML splitting from this PR? We'll open a new PR based on this one after you do so where we can work on the splitting part separately.

Note: this also means that your last commit that introduces the common file should drop all the changes that are being done to the YAML.

The YAML changes causes a lot of conflicts with any other PRs while the code changes do not, and it'll also put the code commits in logical ordering 🙂

@@ -0,0 +1,1243 @@
---
.common:
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should just allow arbitrary top-level keys in the decoding, or introduce a second common section in the ImageTypesYAML so we can have two areas for people to define shared things. Let's start with a .global in imagetypes.yaml and rename the _common.yaml to _global.yaml.

Some things are shared 'globally' across all imagetype yaml's but some here clearly belong inside the variant YAMLs (such as the server package sets; they'd live inside server.yaml, etc).

@avitova avitova force-pushed the split-imgtypes branch 2 times, most recently from a093674 to bd48457 Compare March 16, 2026 11:28
@avitova
Copy link
Contributor Author

avitova commented Mar 16, 2026

Great, I dropped everything that seems to create conflicts.

@avitova avitova marked this pull request as ready for review March 16, 2026 11:37
@avitova avitova requested a review from a team as a code owner March 16, 2026 11:37
@avitova avitova requested review from bcl, lzap and supakeen March 16, 2026 11:37
@supakeen supakeen dismissed their stale review March 16, 2026 11:37

Undrafted.

@supakeen
Copy link
Member

This PR is ready for review, I'll be creating a PR based on this one to show what split imagetypes would actually look like in practice. We decided to do that separately since it will almost continuously conflict with anything.

Some questions we can ask ourselves:

  1. Do we want to prepend distros.yaml instead of a special file? My hunch is no; it'd require allowing specifying imagetypes within distros.yaml as well and probably a bunch of special casing for the defs path?
  2. Do we want to expand so that we prepend all files starting with _ in the defspath? Probably YAGNI for now.

@supakeen supakeen requested review from achilleas-k and thozza March 16, 2026 11:40
@supakeen supakeen mentioned this pull request Mar 16, 2026
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.

The PR title suggests this will in fact split the Fedora image types. I understand we want to do this separately. But it'd be nice to see if this change is functional. Maybe we don't need to split everything all at once, but one image type can be moved to a separate file to see that this actually works.

Regardless, the PR title should be updated.

As for the test failures in GitLab, it seems everything's running correctly but the execution fails during cleanup (or during cache updates)? Not our own cache though, the gitlab one. Is this related to the recent changes in the terraform executor?

@supakeen
Copy link
Member

supakeen commented Mar 17, 2026

The PR title suggests this will in fact split the Fedora image types. I understand we want to do this separately. But it'd be nice to see if this change is functional. Maybe we don't need to split everything all at once, but one image type can be moved to a separate file to see that this actually works.

Regardless, the PR title should be updated.

There's #2266 that actually implements the split so you can see what it looks like; we wanted to keep it out of this PR because it constantly conflicts (as you can see; that PR conflicts right now as well and it's only half a day old :>).

As for the test failures in GitLab, it seems everything's running correctly but the execution fails during cleanup (or during cache updates)? Not our own cache though, the gitlab one. Is this related to the recent changes in the terraform executor?

I've rebased on main where I think these issues are now fixed :)

@avitova avitova changed the title many: HMS-10300 split imagetypes.yaml many: HMS-10300 prepare splitting of imagetypes.yaml Mar 17, 2026
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.

Nice work!

I had a big comment in the first commit, that the distro-level ImageConfig should be moved out from image types YAML to the distro YAML with this split, only to find out that you did it in the next commit. So KUDOS for that 👏

On a general note, I've added a few nitpicks that I'd like to see addressed or at least discussed.

Also WRT commit messages, we tend to use imperative speech in general.

if d.DistroImageConfig != nil {
return d.DistroImageConfig.For(d.ID)
}
return &distro.ImageConfig{}
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: the function would previously return nil, not a pointer to an empty struct.,

Copy link
Contributor Author

@avitova avitova Mar 18, 2026

Choose a reason for hiding this comment

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

oh, good catch, ty
fixed

Comment on lines +298 to +304
count := 0
for _, cfg := range configs {
count += len(cfg.ImageTypes)
}

if count > 0 {
d.imageTypes = make(map[string]ImageTypeYAML, count)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: this is unrelated to the commit it appears in, but it also changes the behavior. Previously, the d.imageTypes would be initialized only when it was nil, now it will be overwritten by a new value regardless of its original value if count > 0.

Moreover, you could simply return if count == 0.

Lastly, I'm not convinced that counting the image types from configs in a separate loop, just to allocate the map precisely is worth it. It adds complexity for marginal benefit and Go will keep some buffer and it is quite efficient when growing the map. It is unlikely that we will have thousands of image types defined in a distribution, so not specifying the size of the map should be acceptable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, this helps us not allocate a pointer to an empty map into imageTypes which is what happened with the previous version.
We can also do
d.imageTypes = make(map[string]ImageTypeYAML) as we previously did, and then if it is empty by the end of the function, we can set it back to nil - maybe even in a defer, but I don't like that either.

Copy link
Member

@achilleas-k achilleas-k Mar 18, 2026

Choose a reason for hiding this comment

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

I think it would be a lot cleaner and avoid pre-counting if we loaded everything into a separate map and skipped assigning it in the end if it's empty (to preserve nil).

imageTypes := make(map[string]ImageTypeYAML)
for _, cfg := range configs {
    for name, v := cfg.ImageTypes {
        ... load etc ...
    }
}

if len(imageTypes) > 0 {
    d.imageTypes = imageTypes
}

We're going to run through configs and image types anyway, no need to do it twice. The total count (len(imageTypes)) is right there in the end.

imageTypes map[string]ImageTypeYAML
// distro wide default image config
imageConfig *distro.ImageConfig `yaml:"default"`
DistroImageConfig *distroImageConfig `yaml:"image_config,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Why the name change? This is a property of DistroYAML, so I think it's clear that it's an ImageConfig for the distro already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to have the field public, but there is already a method called ImageCongig, so there is a collision. 🥲

Copy link
Member

Choose a reason for hiding this comment

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

I don't see any public use of the field, but maybe that's part of the follow-up?

Copy link
Member

@supakeen supakeen Mar 18, 2026

Choose a reason for hiding this comment

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

The reason is that private fields aren't deserialized (and the rest is the name clash).

Comment on lines +298 to +304
count := 0
for _, cfg := range configs {
count += len(cfg.ImageTypes)
}

if count > 0 {
d.imageTypes = make(map[string]ImageTypeYAML, count)
Copy link
Member

@achilleas-k achilleas-k Mar 18, 2026

Choose a reason for hiding this comment

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

I think it would be a lot cleaner and avoid pre-counting if we loaded everything into a separate map and skipped assigning it in the end if it's empty (to preserve nil).

imageTypes := make(map[string]ImageTypeYAML)
for _, cfg := range configs {
    for name, v := cfg.ImageTypes {
        ... load etc ...
    }
}

if len(imageTypes) > 0 {
    d.imageTypes = imageTypes
}

We're going to run through configs and image types anyway, no need to do it twice. The total count (len(imageTypes)) is right there in the end.

@avitova avitova force-pushed the split-imgtypes branch 2 times, most recently from f27b3f0 to e85fbe6 Compare March 18, 2026 12:37
@avitova avitova requested review from achilleas-k and thozza March 18, 2026 12:37
@avitova
Copy link
Contributor Author

avitova commented Mar 18, 2026

Thank you everyone for your reviews. I tried to address everyone's comments, I did keep the name of the field though, I am open to renaming it back if we find a nice way to solve this. :)

avitova added 5 commits March 18, 2026 13:55
Update LoadImageTypes to search for all relevant files in the folder,
add image type from each of those. The function allows for each image
type to appear in only one file.
Move the image config field from the image types yaml into distro
definitions. Allow image types to contain only definitions of image
types.
Remove anchors defined in imagetypes.yaml that were not used anywhere
in the yaml.
Remove the default_kernel_options which was unused for fedora, and
had also a typo.
Add a logic for prepending a file _common.yaml in front of other yaml
image types. Allow splitting yaml files while keeping common anchors.
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.

Thank you. With all the comments addressed this is a great start to offering more options for organizing image types and our YAML in general (and moving image_config into the distro YAML is something I've wanted for a while).

I'm sure (some) things will change in the future in how all of this works but there's nothing that's actively bad in this PR 🙂.


I'll continue on #2266 so we can discuss there what the final form would/could look like (as soon as I get it non-conflicting again).

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