diff --git a/internal/disk/disk.go b/internal/disk/disk.go index 10545c838..3024071f2 100644 --- a/internal/disk/disk.go +++ b/internal/disk/disk.go @@ -151,10 +151,13 @@ func newRandomUUIDFromReader(r io.Reader) (uuid.UUID, error) { return id, nil } -// NewRandomVolIDFromReader creates a random 32 bit hex string to use as a +// NewVolIDFromRand creates a random 32 bit hex string to use as a // volume ID for FAT filesystems -func NewRandomVolIDFromReader(r io.Reader) (string, error) { +func NewVolIDFromRand(r *rand.Rand) string { volid := make([]byte, 4) - _, err := r.Read(volid) - return hex.EncodeToString(volid), err + len, _ := r.Read(volid) + if len != 4 { + panic("expected four random bytes") + } + return hex.EncodeToString(volid) } diff --git a/internal/distro/rhel86/pipelines.go b/internal/distro/rhel86/pipelines.go index ed96d8a68..b28c33489 100644 --- a/internal/distro/rhel86/pipelines.go +++ b/internal/distro/rhel86/pipelines.go @@ -693,7 +693,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO()) isolabel := fmt.Sprintf(d.isolabelTmpl, archName) efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO()) - bootISOTreePipeline := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer) + bootISOTreePipeline := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer, rng) pipelines = append(pipelines, *installerTreePipeline, *efibootTreePipeline, *bootISOTreePipeline) pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), false)) @@ -701,7 +701,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu return pipelines, nil } -func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *osbuild.Pipeline { +func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rng *rand.Rand) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "bootiso-tree" p.Build = "name:build" @@ -741,6 +741,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *o Payload: &disk.Filesystem{ Type: "vfat", Mountpoint: "/", + UUID: disk.NewVolIDFromRand(rng), }, }, }, diff --git a/internal/distro/rhel90/pipelines.go b/internal/distro/rhel90/pipelines.go index 72d554564..debb33e7e 100644 --- a/internal/distro/rhel90/pipelines.go +++ b/internal/distro/rhel90/pipelines.go @@ -692,10 +692,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO()) isolabel := fmt.Sprintf(d.isolabelTmpl, archName) efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO()) - bootISOTreePipeline, err := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer, rng) - if err != nil { - return nil, err - } + bootISOTreePipeline := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer, rng) pipelines = append(pipelines, *installerTreePipeline, *efibootTreePipeline, *bootISOTreePipeline) pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), false)) @@ -703,7 +700,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu return pipelines, nil } -func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rng *rand.Rand) (*osbuild.Pipeline, error) { +func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rng *rand.Rand) *osbuild.Pipeline { p := new(osbuild.Pipeline) p.Name = "bootiso-tree" p.Build = "name:build" @@ -733,11 +730,6 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn }, )) - // TODO: handle error - volid, err := disk.NewRandomVolIDFromReader(rng) - if err != nil { - return nil, err - } pt := disk.PartitionTable{ Size: 20971520, Partitions: []disk.Partition{ @@ -747,7 +739,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn Payload: &disk.Filesystem{ Type: "vfat", Mountpoint: "/", - UUID: volid, + UUID: disk.NewVolIDFromRand(rng), }, }, }, @@ -798,7 +790,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn copyInputs, )) - return p, nil + return p } func simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel string, fdo *blueprint.FDOCustomization) *osbuild.Pipeline { diff --git a/test/data/manifests/centos_8-aarch64-edge_simplified_installer-boot.json b/test/data/manifests/centos_8-aarch64-edge_simplified_installer-boot.json index 48faea8ce..db1277f4b 100644 --- a/test/data/manifests/centos_8-aarch64-edge_simplified_installer-boot.json +++ b/test/data/manifests/centos_8-aarch64-edge_simplified_installer-boot.json @@ -1315,7 +1315,7 @@ { "type": "org.osbuild.mkfs.fat", "options": { - "volid": "" + "volid": "a178892e" }, "devices": { "device": { diff --git a/test/data/manifests/centos_8-x86_64-edge_simplified_installer-boot.json b/test/data/manifests/centos_8-x86_64-edge_simplified_installer-boot.json index c41b830a3..dfac934ec 100644 --- a/test/data/manifests/centos_8-x86_64-edge_simplified_installer-boot.json +++ b/test/data/manifests/centos_8-x86_64-edge_simplified_installer-boot.json @@ -1358,7 +1358,7 @@ { "type": "org.osbuild.mkfs.fat", "options": { - "volid": "" + "volid": "a178892e" }, "devices": { "device": { diff --git a/test/data/manifests/rhel_86-aarch64-edge_simplified_installer-boot.json b/test/data/manifests/rhel_86-aarch64-edge_simplified_installer-boot.json index 60e0ab3aa..48853012b 100644 --- a/test/data/manifests/rhel_86-aarch64-edge_simplified_installer-boot.json +++ b/test/data/manifests/rhel_86-aarch64-edge_simplified_installer-boot.json @@ -1312,7 +1312,7 @@ { "type": "org.osbuild.mkfs.fat", "options": { - "volid": "" + "volid": "a178892e" }, "devices": { "device": { diff --git a/test/data/manifests/rhel_86-x86_64-edge_simplified_installer-boot.json b/test/data/manifests/rhel_86-x86_64-edge_simplified_installer-boot.json index 78b8b22c3..dea914ec7 100644 --- a/test/data/manifests/rhel_86-x86_64-edge_simplified_installer-boot.json +++ b/test/data/manifests/rhel_86-x86_64-edge_simplified_installer-boot.json @@ -1355,7 +1355,7 @@ { "type": "org.osbuild.mkfs.fat", "options": { - "volid": "" + "volid": "a178892e" }, "devices": { "device": {