Skip to content

Commit faffa4c

Browse files
committed
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 <artem.chernyshev@talos-systems.com>
1 parent 07b9179 commit faffa4c

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

cmd/talosctl/cmd/mgmt/cluster/create.go

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,32 @@ var createCmd = &cobra.Command{
194194
},
195195
}
196196

197+
//nolint:gocyclo
197198
func downloadBootAssets(ctx context.Context) error {
198199
// download & cache images if provides as URLs
199-
for _, downloadableImage := range []*string{
200-
&nodeVmlinuzPath,
201-
&nodeInitramfsPath,
202-
&nodeISOPath,
203-
&nodeDiskImagePath,
200+
for _, downloadableImage := range []struct {
201+
path *string
202+
disableArchive bool
203+
}{
204+
{
205+
path: &nodeVmlinuzPath,
206+
},
207+
{
208+
path: &nodeInitramfsPath,
209+
disableArchive: true,
210+
},
211+
{
212+
path: &nodeISOPath,
213+
},
214+
{
215+
path: &nodeDiskImagePath,
216+
},
204217
} {
205-
if *downloadableImage == "" {
218+
if *downloadableImage.path == "" {
206219
continue
207220
}
208221

209-
u, err := url.Parse(*downloadableImage)
222+
u, err := url.Parse(*downloadableImage.path)
210223
if err != nil || !(u.Scheme == "http" || u.Scheme == "https") {
211224
// not a URL
212225
continue
@@ -229,7 +242,7 @@ func downloadBootAssets(ctx context.Context) error {
229242

230243
_, err = os.Stat(filepath.Join(cacheDir, destPath))
231244
if err == nil {
232-
*downloadableImage = filepath.Join(cacheDir, destPath)
245+
*downloadableImage.path = filepath.Join(cacheDir, destPath)
233246

234247
// already cached
235248
continue
@@ -246,6 +259,14 @@ func downloadBootAssets(ctx context.Context) error {
246259
},
247260
}
248261

262+
if downloadableImage.disableArchive {
263+
q := u.Query()
264+
265+
q.Set("archive", "false")
266+
267+
u.RawQuery = q.Encode()
268+
}
269+
249270
_, err = client.Get(ctx, &getter.Request{
250271
Src: u.String(),
251272
Dst: filepath.Join(cacheDir, destPath),
@@ -258,7 +279,7 @@ func downloadBootAssets(ctx context.Context) error {
258279
return err
259280
}
260281

261-
*downloadableImage = filepath.Join(cacheDir, destPath)
282+
*downloadableImage.path = filepath.Join(cacheDir, destPath)
262283
}
263284

264285
return nil

0 commit comments

Comments
 (0)