upload: default to boot-mode uefi-preferred when unset

When using `image-builder upload --to=aws` we do not know
the bootmode. Ideally we would introspect the image for
the boot mode but that is not trivial right now.

So for now just default to platform.BOOT_HYBRID which
translated to `uefi-preferred` in the AWS API calls
which should offer the widest compatbility and should
fix the issue that aarch64 does not boot currently
when uploaded via ibcli.
This commit is contained in:
Michael Vogt 2025-06-03 12:00:54 +02:00 committed by Achilleas Koutsou
parent 62bf88cc62
commit 2c017fc630
2 changed files with 12 additions and 3 deletions

View file

@ -89,6 +89,16 @@ func uploaderForCmdAWS(cmd *cobra.Command, bootMode *platform.BootMode) (cloud.U
if err != nil { if err != nil {
return nil, err return nil, err
} }
if bootMode == nil {
// If unset, default to BOOT_HYBIRD which translated
// to "uefi-prefered" when registering the image.
// This should give us wide compatibility. Ideally
// we would introspect the image but we have no
// metadata there right now.
// XXX: move this into the "images" library itself?
bootModeHybrid := platform.BOOT_HYBRID
bootMode = &bootModeHybrid
}
var missing []string var missing []string
requiredArgs := []string{"aws-ami-name", "aws-bucket", "aws-region"} requiredArgs := []string{"aws-ami-name", "aws-bucket", "aws-region"}
@ -126,8 +136,6 @@ func cmdUpload(cmd *cobra.Command, args []string) error {
} }
imagePath := args[0] imagePath := args[0]
// XXX: we need a way to introspect the image for bootmode here
// and/or error if no bootmode is specified
uploader, err := uploaderFor(cmd, uploadTo, nil) uploader, err := uploaderFor(cmd, uploadTo, nil)
if err != nil { if err != nil {
return err return err

View file

@ -92,7 +92,8 @@ func TestUploadWithAWSMock(t *testing.T) {
assert.Equal(t, regionName, "aws-region-1") assert.Equal(t, regionName, "aws-region-1")
assert.Equal(t, bucketName, "aws-bucket-2") assert.Equal(t, bucketName, "aws-bucket-2")
assert.Equal(t, amiName, "aws-ami-3") assert.Equal(t, amiName, "aws-ami-3")
assert.Equal(t, &awscloud.UploaderOptions{TargetArch: tc.expectedUploadArch}, uploadOpts) expectedBootMode := platform.BOOT_HYBRID
assert.Equal(t, &awscloud.UploaderOptions{TargetArch: tc.expectedUploadArch, BootMode: &expectedBootMode}, uploadOpts)
assert.Equal(t, 0, fa.checkCalls) assert.Equal(t, 0, fa.checkCalls)
assert.Equal(t, 1, fa.uploadAndRegisterCalls) assert.Equal(t, 1, fa.uploadAndRegisterCalls)