Skip to content

Commit

Permalink
fix: generation of SBC images
Browse files Browse the repository at this point in the history
The fix is in siderolabs/talos#8076

Also bump the hash to flush the SBC cached images.

Fixes #65

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Dec 15, 2023
1 parent 25fc50d commit 296e953
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 6 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions internal/integration/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions internal/profile/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
74 changes: 74 additions & 0 deletions internal/profile/hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
17 changes: 17 additions & 0 deletions internal/profile/profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand Down

0 comments on commit 296e953

Please sign in to comment.