From faffa4c3f1382a8b249e12ad9c968240b58b6650 Mon Sep 17 00:00:00 2001 From: Artem Chernyshev Date: Thu, 5 Sep 2024 19:58:15 +0300 Subject: [PATCH] fix: never unarchive initramfs when loading boot assets in talosctl The initramfs unarchive won't work as it's extension is `xz` while the actual compression is `zst`. Signed-off-by: Artem Chernyshev --- cmd/talosctl/cmd/mgmt/cluster/create.go | 39 +++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/cmd/talosctl/cmd/mgmt/cluster/create.go b/cmd/talosctl/cmd/mgmt/cluster/create.go index 382cdb17dc..a394afcc51 100644 --- a/cmd/talosctl/cmd/mgmt/cluster/create.go +++ b/cmd/talosctl/cmd/mgmt/cluster/create.go @@ -194,19 +194,32 @@ var createCmd = &cobra.Command{ }, } +//nolint:gocyclo func downloadBootAssets(ctx context.Context) error { // download & cache images if provides as URLs - for _, downloadableImage := range []*string{ - &nodeVmlinuzPath, - &nodeInitramfsPath, - &nodeISOPath, - &nodeDiskImagePath, + for _, downloadableImage := range []struct { + path *string + disableArchive bool + }{ + { + path: &nodeVmlinuzPath, + }, + { + path: &nodeInitramfsPath, + disableArchive: true, + }, + { + path: &nodeISOPath, + }, + { + path: &nodeDiskImagePath, + }, } { - if *downloadableImage == "" { + if *downloadableImage.path == "" { continue } - u, err := url.Parse(*downloadableImage) + u, err := url.Parse(*downloadableImage.path) if err != nil || !(u.Scheme == "http" || u.Scheme == "https") { // not a URL continue @@ -229,7 +242,7 @@ func downloadBootAssets(ctx context.Context) error { _, err = os.Stat(filepath.Join(cacheDir, destPath)) if err == nil { - *downloadableImage = filepath.Join(cacheDir, destPath) + *downloadableImage.path = filepath.Join(cacheDir, destPath) // already cached continue @@ -246,6 +259,14 @@ func downloadBootAssets(ctx context.Context) error { }, } + if downloadableImage.disableArchive { + q := u.Query() + + q.Set("archive", "false") + + u.RawQuery = q.Encode() + } + _, err = client.Get(ctx, &getter.Request{ Src: u.String(), Dst: filepath.Join(cacheDir, destPath), @@ -258,7 +279,7 @@ func downloadBootAssets(ctx context.Context) error { return err } - *downloadableImage = filepath.Join(cacheDir, destPath) + *downloadableImage.path = filepath.Join(cacheDir, destPath) } return nil