Repository navigation
Conversation
0e1cd21 to
149c146
Compare
| if common.VersionGreaterThanOrEqual(d.osVersion, "42") { | ||
| rootPartition := &iotBasePartitionTables[arch.ARCH_X86_64.String()].Partitions[2] | ||
| rootPartition.Payload.(*disk.Filesystem).FSTabOptions += ",ro" | ||
| } |
There was a problem hiding this comment.
For this kind of change we make partition table functions that are parameterised on the OS version.
See for example these RHEL 9 partition tables: https://github.com/osbuild/images/blob/c25ea613b3b81c2e6640e945c638cbe08b58818a/pkg/distro/rhel/rhel9/partition_tables.go#L13
Can you change this to work the same way? I.e., change iotBasePartitionTables to be a function with an imageType argument that the function can read to determine which partition table to return (based on architecture) and what modifications to make.
This also saves us from any potential side effects of modifying the partition table globals for one Fedora version and generating the wrong manifest for another Fedora version with the modified partition table.
There was a problem hiding this comment.
Yep I should be able to do that 👍
There was a problem hiding this comment.
@achilleas-k Struggling with how to extract an image struct or something similar to .ImageType out of Fedora, I can't find any functions that perform a similar duty in the Fedora package (https://pkg.go.dev/github.com/osbuild/[email protected]/pkg/distro/fedora). Does using functions from the Distro package make sense instead (https://pkg.go.dev/github.com/osbuild/images/pkg/distro)? I was thinking maybe I could use distro.Arch in some way.
There was a problem hiding this comment.
I think it's not needed. The Fedora imageType struct is local to the fedora package and so are the partition tables. So the function conversion can be done like this:
diff --git a/pkg/distro/fedora/partition_tables.go b/pkg/distro/fedora/partition_tables.go
index de4bb4044..c16ccf0cd 100644
--- a/pkg/distro/fedora/partition_tables.go
+++ b/pkg/distro/fedora/partition_tables.go
@@ -355,99 +355,102 @@ var minimalrawPartitionTables = distro.BasePartitionTableMap{
},
}
-var iotBasePartitionTables = distro.BasePartitionTableMap{
- arch.ARCH_X86_64.String(): disk.PartitionTable{
- UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
- Type: disk.PT_GPT,
- StartOffset: 8 * datasizes.MebiByte,
- Partitions: []disk.Partition{
- {
- Size: 501 * datasizes.MebiByte,
- Type: disk.EFISystemPartitionGUID,
- UUID: disk.EFISystemPartitionUUID,
- Payload: &disk.Filesystem{
- Type: "vfat",
- UUID: disk.EFIFilesystemUUID,
- Mountpoint: "/boot/efi",
- Label: "EFI-SYSTEM",
- FSTabOptions: "umask=0077,shortname=winnt",
- FSTabFreq: 0,
- FSTabPassNo: 2,
+func iotBasePartitionTables(t *imageType) disk.PartitionTable {
+ archName := t.arch.name
+ return distro.BasePartitionTableMap{
+ arch.ARCH_X86_64.String(): disk.PartitionTable{
+ UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
+ Type: disk.PT_GPT,
+ StartOffset: 8 * datasizes.MebiByte,
+ Partitions: []disk.Partition{
+ {
+ Size: 501 * datasizes.MebiByte,
+ Type: disk.EFISystemPartitionGUID,
+ UUID: disk.EFISystemPartitionUUID,
+ Payload: &disk.Filesystem{
+ Type: "vfat",
+ UUID: disk.EFIFilesystemUUID,
+ Mountpoint: "/boot/efi",
+ Label: "EFI-SYSTEM",
+ FSTabOptions: "umask=0077,shortname=winnt",
+ FSTabFreq: 0,
+ FSTabPassNo: 2,
+ },
},
- },
- {
- Size: 1 * datasizes.GibiByte,
- Type: disk.FilesystemDataGUID,
- UUID: disk.DataPartitionUUID,
- Payload: &disk.Filesystem{
- Type: "ext4",
- Mountpoint: "/boot",
- Label: "boot",
- FSTabOptions: "defaults",
- FSTabFreq: 1,
- FSTabPassNo: 2,
+ {
+ Size: 1 * datasizes.GibiByte,
+ Type: disk.FilesystemDataGUID,
+ UUID: disk.DataPartitionUUID,
+ Payload: &disk.Filesystem{
+ Type: "ext4",
+ Mountpoint: "/boot",
+ Label: "boot",
+ FSTabOptions: "defaults",
+ FSTabFreq: 1,
+ FSTabPassNo: 2,
+ },
},
- },
- {
- Size: 2569 * datasizes.MebiByte,
- Type: disk.FilesystemDataGUID,
- UUID: disk.RootPartitionUUID,
- Payload: &disk.Filesystem{
- Type: "ext4",
- Label: "root",
- Mountpoint: "/",
- FSTabOptions: "defaults,ro",
- FSTabFreq: 1,
- FSTabPassNo: 1,
+ {
+ Size: 2569 * datasizes.MebiByte,
+ Type: disk.FilesystemDataGUID,
+ UUID: disk.RootPartitionUUID,
+ Payload: &disk.Filesystem{
+ Type: "ext4",
+ Label: "root",
+ Mountpoint: "/",
+ FSTabOptions: "defaults,ro",
+ FSTabFreq: 1,
+ FSTabPassNo: 1,
+ },
},
},
},
- },
- arch.ARCH_AARCH64.String(): disk.PartitionTable{
- UUID: "0xc1748067",
- Type: disk.PT_DOS,
- StartOffset: 8 * datasizes.MebiByte,
- Partitions: []disk.Partition{
- {
- Size: 501 * datasizes.MebiByte,
- Type: disk.FAT16BDOSID,
- Bootable: true,
- Payload: &disk.Filesystem{
- Type: "vfat",
- UUID: disk.EFIFilesystemUUID,
- Mountpoint: "/boot/efi",
- Label: "EFI-SYSTEM",
- FSTabOptions: "umask=0077,shortname=winnt",
- FSTabFreq: 0,
- FSTabPassNo: 2,
+ arch.ARCH_AARCH64.String(): disk.PartitionTable{
+ UUID: "0xc1748067",
+ Type: disk.PT_DOS,
+ StartOffset: 8 * datasizes.MebiByte,
+ Partitions: []disk.Partition{
+ {
+ Size: 501 * datasizes.MebiByte,
+ Type: disk.FAT16BDOSID,
+ Bootable: true,
+ Payload: &disk.Filesystem{
+ Type: "vfat",
+ UUID: disk.EFIFilesystemUUID,
+ Mountpoint: "/boot/efi",
+ Label: "EFI-SYSTEM",
+ FSTabOptions: "umask=0077,shortname=winnt",
+ FSTabFreq: 0,
+ FSTabPassNo: 2,
+ },
},
- },
- {
- Size: 1 * datasizes.GibiByte,
- Type: disk.FilesystemLinuxDOSID,
- Payload: &disk.Filesystem{
- Type: "ext4",
- Mountpoint: "/boot",
- Label: "boot",
- FSTabOptions: "defaults",
- FSTabFreq: 1,
- FSTabPassNo: 2,
+ {
+ Size: 1 * datasizes.GibiByte,
+ Type: disk.FilesystemLinuxDOSID,
+ Payload: &disk.Filesystem{
+ Type: "ext4",
+ Mountpoint: "/boot",
+ Label: "boot",
+ FSTabOptions: "defaults",
+ FSTabFreq: 1,
+ FSTabPassNo: 2,
+ },
},
- },
- {
- Size: 2569 * datasizes.MebiByte,
- Type: disk.FilesystemLinuxDOSID,
- Payload: &disk.Filesystem{
- Type: "ext4",
- Label: "root",
- Mountpoint: "/",
- FSTabOptions: "defaults",
- FSTabFreq: 1,
- FSTabPassNo: 1,
+ {
+ Size: 2569 * datasizes.MebiByte,
+ Type: disk.FilesystemLinuxDOSID,
+ Payload: &disk.Filesystem{
+ Type: "ext4",
+ Label: "root",
+ Mountpoint: "/",
+ FSTabOptions: "defaults",
+ FSTabFreq: 1,
+ FSTabPassNo: 1,
+ },
},
},
},
- },
+ }[archName]
}
var iotSimplifiedInstallerPartitionTables = distro.BasePartitionTableMap{and then the fstab options can be modified based on the distro version after that.
There was a problem hiding this comment.
Actually, looking at it now, it looks like it's going to be a bigger change than I originally though, because we would have to change the type of the partition table property on Fedora's imageType to a function (like in RHEL).
Maybe it's better if we leave it for a follow-up.
There was a problem hiding this comment.
Gotcha, I just force pushed to bring the branch up to date. Thanks for the detailed rundown, I think I understand a little better.
There was a problem hiding this comment.
Fwiw, converting to a function (like in the rhel image types) is done in #1362 and with the YAML-ification all of partition_table.go is going away so doing something short term here seems fine. How urgent is this work? Alternatively we could update 1362 for conditionals and then do this change in the YAML instead of in code.
With this requirement pr 1362 will need conditionals in the YAML which is fine and we also need it in RHEL but it does mean the PR there will get bigger. So if we need this change soon we should probably do something short term here. If it can wait a few days we can tweak 1362 to have conditionals and do it in the yaml.
There was a problem hiding this comment.
Fwiw, I pushed support for conditional overrides into #1362, it looks like this for this specific use-case:
iot_raw_image:
partition_table:
<<: *iot_base_partition_tables
partition_table_override:
condition:
version_greater_or_equal:
"42":
- select_partition: 2
fstab_options: "defaults,ro"There was a problem hiding this comment.
Thanks for making these changes in the yaml, I don't think this is super urgent. Would you like me to wait on this until the yaml changes come out?
There was a problem hiding this comment.
I just approved the partition table yaml-ification PR, so maybe let's do it there, yeah.
Signed-off-by: djach7 <[email protected]>
149c146 to
d949a53
Compare
|
|
||
| func mkIotRawImgType(d distribution) imageType { | ||
| if common.VersionGreaterThanOrEqual(d.osVersion, "42") { | ||
| rootPartition := &iotBasePartitionTables[arch.ARCH_X86_64.String()].Partitions[2] |
There was a problem hiding this comment.
Quick question @djach7 - only x86_64 or should we also update aarch64 for ro?
There was a problem hiding this comment.
We do need it, I've been slacking on aarch I apologize. I'll update/rewrite this to account for that too. I think I'm going to change this into an iterator that steps through each partition, I'm not sure if I can be confident that the root partition will always be at [2].
There was a problem hiding this comment.
It looks like #1362 (review) might get merged soon, - that branch includes this change now via the new partition_override yaml.
There was a problem hiding this comment.
Gotcha, I'll hold back on this for now then.
This is doing the equivalent of osbuild#1352
This is doing the equivalent of osbuild#1352
This is doing the equivalent of osbuild#1352
This is doing the equivalent of osbuild#1352
|
Making this a draft until I get the aarch changes added today |
This is doing the equivalent of #1352
Originally added in f77bd7b, we wanted to pin the version to ensure that we were targeting the latest version of Go 1.21. However, there's no real value here, and as noted in [0] it can be causing issues for some users. There's nothing explicitly in Go 1.21.x that we need to pin to, just that we need support for Go 1.21, so we can use Speakeasy's `openapi-overlay` library. Therefore we can relax the patch-version requirement, which will alleviate issues for consumers. This makes sure that we have _at a minimum_ a version of Go 1.21, and makes `go mod tidy` happy. [0]: osbuild/image-builder#1352
Updates IoT fstab to only include
roin versions 42 and above.Follow up to this PR: #1346
Fix for this issue: fedora-iot/iot-distro#81
Going to start this out as a draft to confirm that this is the only location
rois needed.