From 01bb294af63f193dafa12cb623ea77ad67b698fb Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Thu, 1 May 2025 19:39:44 +0530 Subject: [PATCH] fix(ci): provision tests Fix the provision-0 cron tests. Support zstd disk images for `talosctl cluster create`. Signed-off-by: Noel Georgi --- .github/workflows/ci.yaml | 10 ++++- .../integration-provision-0-cron.yaml | 10 ++++- .kres.yaml | 7 ++++ .../cmd/mgmt/cluster/create/create.go | 2 + hack/test/e2e-qemu.sh | 3 +- hack/test/provision-tests.sh | 2 - internal/integration/provision/upgrade.go | 2 +- pkg/provision/providers/qemu/node.go | 40 ++++++++++++++----- 8 files changed, 60 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 522443509..5580681d2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2025-04-15T15:57:38Z by kres fd5cab0. +# Generated on 2025-05-01T14:09:23Z by kres 6cbcbd1. name: default concurrency: @@ -2998,6 +2998,14 @@ jobs: if: github.event_name == 'schedule' run: | make talosctl-cni-bundle + - name: images-essential + if: github.event_name == 'schedule' + env: + IMAGE_REGISTRY: registry.dev.siderolabs.io + IMAGER_ARGS: --extra-kernel-arg=console=ttyS0 + PLATFORM: linux/amd64,linux/arm64 + run: | + make images-essential - name: provision-tests-prepare run: | make provision-tests-prepare diff --git a/.github/workflows/integration-provision-0-cron.yaml b/.github/workflows/integration-provision-0-cron.yaml index f975f62d0..a3d1f7c1f 100644 --- a/.github/workflows/integration-provision-0-cron.yaml +++ b/.github/workflows/integration-provision-0-cron.yaml @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2025-04-01T08:14:24Z by kres d903dae. +# Generated on 2025-05-01T14:09:23Z by kres 6cbcbd1. name: integration-provision-0-cron concurrency: @@ -78,6 +78,14 @@ jobs: if: github.event_name == 'schedule' run: | make talosctl-cni-bundle + - name: images-essential + if: github.event_name == 'schedule' + env: + IMAGE_REGISTRY: registry.dev.siderolabs.io + IMAGER_ARGS: --extra-kernel-arg=console=ttyS0 + PLATFORM: linux/amd64,linux/arm64 + run: | + make images-essential - name: provision-tests-prepare run: | make provision-tests-prepare diff --git a/.kres.yaml b/.kres.yaml index a5c44c3de..84392e049 100644 --- a/.kres.yaml +++ b/.kres.yaml @@ -731,6 +731,13 @@ spec: - name: talosctl-cni-bundle conditions: - only-on-schedule + - name: images-essential + conditions: + - only-on-schedule + environment: + PLATFORM: linux/amd64,linux/arm64 + IMAGER_ARGS: "--extra-kernel-arg=console=ttyS0" + IMAGE_REGISTRY: registry.dev.siderolabs.io - name: provision-tests-prepare - name: provision-tests-track-0 withSudo: true diff --git a/cmd/talosctl/cmd/mgmt/cluster/create/create.go b/cmd/talosctl/cmd/mgmt/cluster/create/create.go index 0a0a70e86..b902ae892 100644 --- a/cmd/talosctl/cmd/mgmt/cluster/create/create.go +++ b/cmd/talosctl/cmd/mgmt/cluster/create/create.go @@ -246,6 +246,8 @@ func downloadBootAssets(ctx context.Context) error { }, { path: &nodeDiskImagePath, + // we disable extracting the compressed image since we handle zstd for disk images + disableArchive: true, }, } { if *downloadableImage.path == "" { diff --git a/hack/test/e2e-qemu.sh b/hack/test/e2e-qemu.sh index 345469254..ef769540d 100755 --- a/hack/test/e2e-qemu.sh +++ b/hack/test/e2e-qemu.sh @@ -106,8 +106,7 @@ case "${USE_DISK_IMAGE:-false}" in false) ;; *) - zstd -d < _out/metal-amd64.raw.zst > _out/metal-amd64.raw - QEMU_FLAGS+=("--disk-image-path=_out/metal-amd64.raw") + QEMU_FLAGS+=("--disk-image-path=_out/metal-amd64.raw.zst") ;; esac diff --git a/hack/test/provision-tests.sh b/hack/test/provision-tests.sh index f396d7df7..4b5050687 100755 --- a/hack/test/provision-tests.sh +++ b/hack/test/provision-tests.sh @@ -39,8 +39,6 @@ case "${CUSTOM_CNI_URL:-false}" in ;; esac -zstd -d < _out/metal-amd64.raw.zst > _out/metal-amd64.raw - "${INTEGRATION_TEST}" -test.v \ -talos.talosctlpath "${TALOSCTL}" \ -talos.provision.mtu 1430 \ diff --git a/internal/integration/provision/upgrade.go b/internal/integration/provision/upgrade.go index ead3fdb2a..420a6f7bc 100644 --- a/internal/integration/provision/upgrade.go +++ b/internal/integration/provision/upgrade.go @@ -147,7 +147,7 @@ func upgradeCurrentToCurrentBios() upgradeSpec { return upgradeSpec{ ShortName: fmt.Sprintf("%s-same-ver-bios", DefaultSettings.CurrentVersion), - SourceDiskImagePath: helpers.ArtifactPath("metal-amd64.raw"), + SourceDiskImagePath: helpers.ArtifactPath("metal-amd64.raw.zst"), SourceInstallerImage: installerImage, SourceVersion: DefaultSettings.CurrentVersion, SourceK8sVersion: currentK8sVersion, diff --git a/pkg/provision/providers/qemu/node.go b/pkg/provision/providers/qemu/node.go index 3dec5d530..dc7570086 100644 --- a/pkg/provision/providers/qemu/node.go +++ b/pkg/provision/providers/qemu/node.go @@ -19,6 +19,7 @@ import ( "github.com/google/uuid" "github.com/hashicorp/go-multierror" + "github.com/klauspost/compress/zstd" "github.com/siderolabs/gen/xslices" "github.com/siderolabs/go-cmd/pkg/cmd" "github.com/siderolabs/go-procfs/procfs" @@ -317,24 +318,45 @@ func (p *provisioner) findBridgeListenPort(clusterReq provision.ClusterRequest) func (p *provisioner) populateSystemDisk(disks []string, clusterReq provision.ClusterRequest) error { if len(disks) > 0 && clusterReq.DiskImagePath != "" { - disk, err := os.OpenFile(disks[0], os.O_RDWR, 0o755) + if err := p.handleOptionalZSTDDiskImage(disks[0], clusterReq.DiskImagePath); err != nil { + return err + } + } + + return nil +} + +func (p *provisioner) handleOptionalZSTDDiskImage(provisionerDisk, diskImagePath string) error { + image, err := os.Open(diskImagePath) + if err != nil { + return err + } + + defer image.Close() //nolint:errcheck + + disk, err := os.OpenFile(provisionerDisk, os.O_RDWR, 0o755) + if err != nil { + return err + } + + defer disk.Close() //nolint:errcheck + + if strings.HasSuffix(diskImagePath, ".zst") { + zstdReader, err := zstd.NewReader(image) if err != nil { return err } - defer disk.Close() //nolint:errcheck - image, err := os.Open(clusterReq.DiskImagePath) - if err != nil { - return err - } - defer image.Close() //nolint:errcheck + defer zstdReader.Close() //nolint:errcheck - _, err = io.Copy(disk, image) + _, err = io.Copy(disk, zstdReader) return err } - return nil + _, err = io.Copy(disk, image) + + return err } func (p *provisioner) createMetalConfigISO(state *vm.State, nodeName, config string) (string, error) {