Skip to content

Commit

Permalink
fix: never unarchive initramfs when loading boot assets in talosctl
Browse files Browse the repository at this point in the history
The initramfs unarchive won't work as it's extension is `xz` while the
actual compression is `zst`.

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
  • Loading branch information
Unix4ever committed Sep 5, 2024
1 parent 07b9179 commit faffa4c
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions cmd/talosctl/cmd/mgmt/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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),
Expand All @@ -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
Expand Down

0 comments on commit faffa4c

Please sign in to comment.