From 296e9533e53d71f369084cead8e44f7db7fdb30c Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 15 Dec 2023 20:14:09 +0400 Subject: [PATCH] fix: generation of SBC images The fix is in https://github.com/siderolabs/talos/pull/8076 Also bump the hash to flush the SBC cached images. Fixes #65 Signed-off-by: Andrey Smirnov --- go.mod | 4 +- go.sum | 4 +- internal/integration/download_test.go | 4 +- internal/profile/hash.go | 7 +++ internal/profile/hash_test.go | 74 +++++++++++++++++++++++++++ internal/profile/profile_test.go | 17 ++++++ 6 files changed, 104 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 7ea8092..3632fd4 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/siderolabs/image-factory -go 1.21.4 +go 1.21.5 require ( github.com/blang/semver/v4 v4.0.0 @@ -11,7 +11,7 @@ require ( github.com/prometheus/client_golang v1.17.0 github.com/siderolabs/gen v0.4.7 github.com/siderolabs/go-pointer v1.0.0 - github.com/siderolabs/talos v1.6.0 + github.com/siderolabs/talos v1.6.0-alpha.2.0.20231215154610-760f793d55f3 github.com/siderolabs/talos/pkg/machinery v1.6.0 github.com/sigstore/cosign/v2 v2.2.1 github.com/sigstore/sigstore v1.7.5 diff --git a/go.sum b/go.sum index bfed082..f4013d0 100644 --- a/go.sum +++ b/go.sum @@ -833,8 +833,8 @@ github.com/siderolabs/net v0.4.0 h1:1bOgVay/ijPkJz4qct98nHsiB/ysLQU0KLoBC4qLm7I= github.com/siderolabs/net v0.4.0/go.mod h1:/ibG+Hm9HU27agp5r9Q3eZicEfjquzNzQNux5uEk0kM= github.com/siderolabs/protoenc v0.2.1 h1:BqxEmeWQeMpNP3R6WrPqDatX8sM/r4t97OP8mFmg6GA= github.com/siderolabs/protoenc v0.2.1/go.mod h1:StTHxjet1g11GpNAWiATgc8K0HMKiFSEVVFOa/H0otc= -github.com/siderolabs/talos v1.6.0 h1:DoB4+PApyx63GGjAfom06hVZMhpUuI+QCke6KLRuios= -github.com/siderolabs/talos v1.6.0/go.mod h1:uJhYUWhyAcfaNyt5FI12zXQgCmdFxr20Y3XYqV1WnRU= +github.com/siderolabs/talos v1.6.0-alpha.2.0.20231215154610-760f793d55f3 h1:RAe8MEBa4Hbs01kWVjy7kv1uY74GOHLGv07zLIOChGg= +github.com/siderolabs/talos v1.6.0-alpha.2.0.20231215154610-760f793d55f3/go.mod h1:yF1v3IJ0EjOXLitXb9mg8LhAbaZSDJ680L4UTNAK3WI= github.com/siderolabs/talos/pkg/machinery v1.6.0 h1:wWtiUMyokCQMH2xkHyNsQj2vfGhRUnjBZ9eRI5kXSi4= github.com/siderolabs/talos/pkg/machinery v1.6.0/go.mod h1:WZ/yDqQLHDfol/gf2qcD2u47+CDX819kEB+RQpAKWAU= github.com/sigstore/cosign/v2 v2.2.1 h1:HauwPOMYYaVdQsnvUbF0P+ZsVPrkTB0G7Eq65+z1bQc= diff --git a/internal/integration/download_test.go b/internal/integration/download_test.go index e99bf3c..04723db 100644 --- a/internal/integration/download_test.go +++ b/internal/integration/download_test.go @@ -233,7 +233,7 @@ func testDownloadFrontend(ctx context.Context, t *testing.T, baseURL string) { t.Run("rpi image", func(t *testing.T) { t.Parallel() - downloadAssetAndMatchSize(ctx, t, baseURL, emptySchematicID, talosVersion, "metal-rpi_generic-arm64.raw.xz", "application/x-xz", 66574172) + downloadAssetAndMatchSize(ctx, t, baseURL, emptySchematicID, talosVersion, "metal-rpi_generic-arm64.raw.xz", "application/x-xz", 107183936) }) }) @@ -264,7 +264,7 @@ func testDownloadFrontend(ctx context.Context, t *testing.T, baseURL string) { t.Run("rpi image", func(t *testing.T) { t.Parallel() - downloadAssetAndMatchSize(ctx, t, baseURL, systemExtensionsSchematicID, talosVersion, "metal-rpi_generic-arm64.raw.xz", "application/x-xz", 94756312) + downloadAssetAndMatchSize(ctx, t, baseURL, systemExtensionsSchematicID, talosVersion, "metal-rpi_generic-arm64.raw.xz", "application/x-xz", 132095368) }) t.Run("initramfs", func(t *testing.T) { diff --git a/internal/profile/hash.go b/internal/profile/hash.go index 57b8088..1dd9c0a 100644 --- a/internal/profile/hash.go +++ b/internal/profile/hash.go @@ -31,6 +31,13 @@ func Hash(p profile.Profile) (string, error) { return "", fmt.Errorf("failed to marshal profile: %w", err) } + // update the hash value to force rebuild assets once the bug is fixed + // + // 1. errata https://github.com/siderolabs/image-factory/issues/65 + if p.Board != "" { + hasher.Write([]byte("board fix #65")) + } + return hex.EncodeToString(hasher.Sum(nil)), nil } diff --git a/internal/profile/hash_test.go b/internal/profile/hash_test.go index 681a899..c973a32 100644 --- a/internal/profile/hash_test.go +++ b/internal/profile/hash_test.go @@ -98,6 +98,80 @@ func TestCleanProfile(t *testing.T) { }, }, }, + { + name: "rpi image profile", + in: profile.Profile{ + Platform: constants.PlatformMetal, + SecureBoot: pointer.To(false), + Arch: "arm64", + Board: "rpi_generic", + Version: "v1.5.5", + Customization: profile.CustomizationProfile{ + ExtraKernelArgs: []string{"net.ifnames=0"}, + }, + Input: profile.Input{ + Kernel: profile.FileAsset{ + Path: "/tmp/foo/kernel-amd64-v1.5.5", + }, + Initramfs: profile.FileAsset{ + Path: "/tmp/foo/initramfs-amd64-v1.5.5", + }, + BaseInstaller: profile.ContainerAsset{ + ImageRef: "ghcr.io/siderolabs/installer:v1.5.5", + OCIPath: "/tmp/foo/installer-amd64-v1.5.5.oci", + }, + SystemExtensions: []profile.ContainerAsset{ + { + TarballPath: "/path/some/c36dec8c835049f60b10b8e02c689c47f775a07e9a9d909786e3aacb30af9675.tar", + }, + }, + }, + Output: profile.Output{ + Kind: profile.OutKindImage, + OutFormat: profile.OutFormatRaw, + ImageOptions: &profile.ImageOptions{ + DiskFormat: profile.DiskFormatRaw, + DiskSize: profile.MinRAWDiskSize, + }, + }, + }, + + expected: profile.Profile{ + Platform: constants.PlatformMetal, + SecureBoot: pointer.To(false), + Arch: "arm64", + Board: "rpi_generic", + Version: "v1.5.5", + Customization: profile.CustomizationProfile{ + ExtraKernelArgs: []string{"net.ifnames=0"}, + }, + Input: profile.Input{ + Kernel: profile.FileAsset{ + Path: "kernel-amd64-v1.5.5", + }, + Initramfs: profile.FileAsset{ + Path: "initramfs-amd64-v1.5.5", + }, + BaseInstaller: profile.ContainerAsset{ + ImageRef: "installer:v1.5.5", + OCIPath: "installer-amd64-v1.5.5.oci", + }, + SystemExtensions: []profile.ContainerAsset{ + { + TarballPath: "c36dec8c835049f60b10b8e02c689c47f775a07e9a9d909786e3aacb30af9675.tar", + }, + }, + }, + Output: profile.Output{ + Kind: profile.OutKindImage, + OutFormat: profile.OutFormatRaw, + ImageOptions: &profile.ImageOptions{ + DiskFormat: profile.DiskFormatRaw, + DiskSize: profile.MinRAWDiskSize, + }, + }, + }, + }, } { t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/internal/profile/profile_test.go b/internal/profile/profile_test.go index 1e6c1c8..f0c5bcd 100644 --- a/internal/profile/profile_test.go +++ b/internal/profile/profile_test.go @@ -164,6 +164,23 @@ func TestParseFromPath(t *testing.T) { }, }, }, + { + path: "metal-rpi_generic-arm64.raw.xz", + + expectedProfile: profile.Profile{ + Platform: "metal", + Arch: "arm64", + Board: "rpi_generic", + Output: profile.Output{ + Kind: profile.OutKindImage, + OutFormat: profile.OutFormatXZ, + ImageOptions: &profile.ImageOptions{ + DiskFormat: profile.DiskFormatRaw, + DiskSize: profile.MinRAWDiskSize, + }, + }, + }, + }, { path: "aws-amd64-secureboot.qcow2.tar.gz",