Skip to content

rhel8,9: move partitioning into YAML (HMS-6021) - #1390

Merged
mvo5 merged 10 commits into
osbuild:mainfrom
mvo5:loader-part-override
Apr 25, 2025
Merged

mvo5 merged 10 commits into
osbuild:mainfrom
mvo5:loader-part-override

Conversation

@mvo5

@mvo5 mvo5 commented Apr 4, 2025 •

Copy link
Copy Markdown
Contributor

This PR moves the rhel8,9 partition tables into YAML. Its a cleaned up version of
#1388
and uses a simplified approach to partition overrides (thanks to Achilleas) compared to
#1372
which is using a reflect/patch-individual fields approach that is more complicated.

Here the idea of this PR is that we only have the ability to fully replace partition tables, e.g.

    ec2_partition_tables_override: &ec2_partition_tables_override
      condition:
        version_less_than:
          <<: *default_partition_tables_override_lt
          "9.3":
            <<: *default_partition_tables_override_lt_9_3
            x86_64:
              <<: *default_partition_table_x86_64
              partitions:
                - *default_partition_table_part_bios
                # note no boot efi
                - *default_partition_table_part_boot512
                - *default_partition_table_part_root
        distro_name:
          "centos":
...

This of course means that only a single override wins and it must be a full partition table. This is not too bad because YAML anchors help a lot, but it gets a bit verbose (rhel-9 has the most complex example).

Another slightly weird thing is that distro name matching always "wins" so that we can have defaults for centos. Here the version match does not work because centos is e.g. version 9 so all overrides for version_less_than 9.X will be applied. We could solve also solve this by making centos an artifical 9.999 version and then all centos distro_name conditions would go away.

Note that we can always move to the "patch individual fields approach in #1372 later.

/jira-epic HMS-5284

JIRA: HMS-6021

@mvo5
mvo5 requested a review from a team as a code owner April 4, 2025 13:56
@mvo5
mvo5 requested review from schuellerf, supakeen and thozza April 4, 2025 13:56
@mvo5
mvo5 force-pushed the loader-part-override branch 5 times, most recently from 6cf56ce to 8add153 Compare April 8, 2025 14:54
@mvo5
mvo5 force-pushed the loader-part-override branch from d154da6 to 10a0273 Compare April 9, 2025 08:08
supakeen
supakeen previously approved these changes Apr 24, 2025

@supakeen supakeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Needs conflict fixes.

mvo5 added 10 commits April 24, 2025 16:27
When we go over conditions that require versions we need to make
sure we sort them first so that if there are multiple version
conditions the way they are applied is predictable. As they
are just map keys in YAML the order is not preditable otherwise.
So with
```
condition
 version_greater_or_equal:
   "1":
     - foo
   "2":
     - bar
```
we need stable ordering to ensure that when e.g. a partition
table is overriden they are executed in order so that the last
change can potentially override the previous one.

Note that this version requires go1.23 which we currently cannot
use. So there is an extra commit to provide a go1.22 version that
we can just revert once we can use go1.23.
This commit should be reverted once we can move to go1.23. It
just ports the (rather nice) `versionLessThanSortedKeys()` helper
to the versions of slices/maps available in go1.22.
This is an alternative implementation of a partition table override
implementation that is *very* simple (thanks Achilleas). With the
right YAML anchor/alias support this will allow overrides for our
current cases. We can look into more complicated schemes (c.f.

Also use the new  `partiton_tables_override` syntax for the existing
fedora partitions.
This commit adds
```
partition_tables_override:
  condition:
    version_less_than:
```
sort as this is needed for rhel-8,99
This commit adds:
```yaml
partition_tables_override:
  condition:
    distro_name:
```
support.
This commit moves the existing rhel8 partition tables into YAML.
This commit moves the existing rhel9 partition tables into YAML.
This test takes a long time already (~30s on my machine) because
it creates manifest for all our 900 image types. With the YAML
based loading it takes about 5x longer (150s on my machine) because
now each manifest creation takes a bit more work (loading/parsing
yaml etc). In CI this meant that we hit the 5min test limit
(sometimes).

By making this test run in parallel we gain a substancial speedup
(from 150s to 11s on my machine) that should fix the CI timeouts.
The TestPipelineRepositories now takes more than the default 10m
test timeout. The reason is that the YAML adds a bit of extra time
for each test-run. But because we run a total of >6_000 subtests
it adds up. And even with "t.Parallel()" with just the default
4 hit runner CPUs we do not win enough speedup.
@mvo5
mvo5 force-pushed the loader-part-override branch from 10a0273 to 7bdc88a Compare April 24, 2025 14:33
@mvo5
mvo5 requested a review from supakeen April 24, 2025 14:33

@thozza thozza left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work. I like it a lot, although I need to get used to all these advanced YAML syntax 😇

size: 111_111_111
`
// XXX: we cannot use distro.Name() as it will give us a name+ver
baseDir := makeFakePkgsSet(t, test_distro.TestDistroNameBase, fakeDistroYaml)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nitpick: it would probably make sense to rename makeFakePkgsSet() to something like makeFakeDefs(), since it seem to be doing more than just package sets.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I will do a small followup with this (and the other suggestions)

Comment on lines +599 to +601
- &ec2_partition_table_part_boot512
<<: *ec2_partition_table_part_boot
size: 536_870_912 # 512MiB

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I love this way of overriding 😍

distro_name:
# we need this override to ensure that centos always gets
# the latest partition-tables, othersie "centos-8" is
# less then "8 <= 8.9"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo: less then -> less than

Comment on lines +33 to 35
func ec2PartitionTables(t *rhel.ImageType) (disk.PartitionTable, bool) {
return partitionTables(t)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suppose you plan to eventually use partitionTables(t) everywhere and remove image-type-specific partition table generator functions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, mostly to keep the diff small but a bit misguided I guess. This will also be part of a small followup.

@mvo5
mvo5 added this pull request to the merge queue Apr 25, 2025
Merged via the queue into osbuild:main with commit 34cdc56 Apr 25, 2025
@mvo5
mvo5 deleted the loader-part-override branch April 25, 2025 08:21
@schutzbot schutzbot changed the title rhel8,9: move partitioning into YAML rhel8,9: move partitioning into YAML (HMS-6021) Apr 28, 2025
achilleas-k added a commit to achilleas-k/osbuild-composer that referenced this pull request Apr 29, 2025
tag v0.140.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.140.0

----------------
  * Loader part override followups (osbuild/image-builder#1466)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza
  * RHEL-10/gce: install cloud-utils-growpart by default (osbuild/image-builder#1463)
    * Author: Tomáš Hozza, Reviewers: Michael Vogt, Simon de Vlieger
  * base-host-check: expand to cover more (COMPOSER-2498) (osbuild/image-builder#1432)
    * Author: Simon de Vlieger, Reviewers: Tomáš Hozza
  * rhel8,9: move partitioning into YAML (osbuild/image-builder#1390)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza

— Somewhere on the Internet, 2025-04-28

---

tag v0.141.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.141.0

----------------
  * Shrink the current installer images a bit (osbuild/image-builder#1423)
    * Author: Brian C. Lane, Reviewers: Achilleas Koutsou, Simon de Vlieger, Tomáš Hozza
  * Update EL10 Azure images with changes made in RHEL 9.6 (osbuild/image-builder#1472)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Tomáš Hozza
  * distro: add DNFSetReleaseVerVar to ImageConfig (osbuild/image-builder#1465)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Tomáš Hozza
  * test/base-host-check.sh: fix disabled firewall services check (osbuild/image-builder#1471)
    * Author: Sanne Raymaekers, Reviewers: Achilleas Koutsou, Tomáš Hozza

— Somewhere on the Internet, 2025-04-29

---
thozza pushed a commit to osbuild/osbuild-composer that referenced this pull request Apr 29, 2025
tag v0.140.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.140.0

----------------
  * Loader part override followups (osbuild/image-builder#1466)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza
  * RHEL-10/gce: install cloud-utils-growpart by default (osbuild/image-builder#1463)
    * Author: Tomáš Hozza, Reviewers: Michael Vogt, Simon de Vlieger
  * base-host-check: expand to cover more (COMPOSER-2498) (osbuild/image-builder#1432)
    * Author: Simon de Vlieger, Reviewers: Tomáš Hozza
  * rhel8,9: move partitioning into YAML (osbuild/image-builder#1390)
    * Author: Michael Vogt, Reviewers: Tomáš Hozza

— Somewhere on the Internet, 2025-04-28

---

tag v0.141.0
Tagger: imagebuilder-bot <[email protected]>

Changes with 0.141.0

----------------
  * Shrink the current installer images a bit (osbuild/image-builder#1423)
    * Author: Brian C. Lane, Reviewers: Achilleas Koutsou, Simon de Vlieger, Tomáš Hozza
  * Update EL10 Azure images with changes made in RHEL 9.6 (osbuild/image-builder#1472)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Tomáš Hozza
  * distro: add DNFSetReleaseVerVar to ImageConfig (osbuild/image-builder#1465)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Tomáš Hozza
  * test/base-host-check.sh: fix disabled firewall services check (osbuild/image-builder#1471)
    * Author: Sanne Raymaekers, Reviewers: Achilleas Koutsou, Tomáš Hozza

— Somewhere on the Internet, 2025-04-29

---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants