Skip to content

Commit 89d09dc

Browse files
fix(k3s): add better error handling to LoadImages
1 parent daabf50 commit 89d09dc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

modules/k3s/k3s.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,14 @@ func (c *K3sContainer) LoadImagesWithOpts(ctx context.Context, images []string,
209209
return fmt.Errorf("copying image to container %w", err)
210210
}
211211

212-
_, _, err = c.Exec(ctx, []string{"ctr", "-n=k8s.io", "images", "import", "--all-platforms", containerPath})
212+
exit, reader, err := c.Exec(ctx, []string{"ctr", "-n=k8s.io", "images", "import", "--all-platforms", containerPath})
213213
if err != nil {
214214
return fmt.Errorf("importing image %w", err)
215215
}
216+
if exit != 0 {
217+
b, _ := io.ReadAll(reader)
218+
return fmt.Errorf("importing image %s", string(b))
219+
}
216220

217221
return nil
218222
}

0 commit comments

Comments
 (0)