Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uefi boot support to compose data [RHELDST-18235] #356

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pushsource/_impl/backend/staged/staged_ami.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __push_item(self, leafdir, metadata, entry):
"description",
"sriov_net_support",
"ena_support",
"uefi_support",
"public_image",
"release_notes",
"usage_instructions",
Expand Down
6 changes: 6 additions & 0 deletions src/pushsource/_impl/model/ami.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ class AmiPushItem(VMIPushItem):
)
"""``True`` if the image supports Elastic Network Adapter (ENA)."""

uefi_support = attr.ib(
type=bool, default=None, validator=optional(instance_of(bool))
)
"""``True`` if the image supports UEFI boot."""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amcmahon-rh It is not such simple boolean value.
Image builder provides additional metadata in koji build e.g.

 'extra': {'typeinfo': {'image': {'rhel-azure-9.3-20230823.14.aarch64.vhd.xz': {'arch': 'aarch64',
                                                                                'boot_mode': 'uefi'},
                                  'rhel-azure-9.3-20230823.14.x86_64.vhd.xz': {'arch': 'x86_64',
                                                                               'boot_mode': 'hybrid'}}}},

aarch64 obviously has to use uefi. But with x86_64 it should try uefi but it can do fallback
in AWS terminology, it is 3 state: "uefi-preferred", "legacy-bios" and "uefi"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lslebodn, I don't quite understand, could you elaborate please?

I understand that AWS requires specific string values. The idea of using a boolean was to keep the value abstract up to the point where we actually interact with AWS, rather than passing string values around different libraries.

Would this be resolved by having a second boolean? One for uefi and one for bios support?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amcmahon-rh there are 4 possible ways for adding "BootMode" for image.
a) missing option "BootMode"
b) one of following values: uefi, legacy-bios, or uefi-preferred as it is described in AWS documentation(https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ami-boot-mode.html)

And we cannot achieve it with current with current "type=bool".

Because based on value of boolean cloudimg can use either "uefi-preferred" or "legacy-bios"

For aarch64 images, "uefi-preferred" is not ideal. It should be either "uefi" or the "BootMode" should not be specified at all when uploading image as it was before this change

billing_codes = attr.ib(
type=AmiBillingCodes,
default=None,
Expand Down Expand Up @@ -199,6 +204,7 @@ def _from_data(cls, data):
"description": data["description"],
"sriov_net_support": data["sriov_net_support"],
"ena_support": data.get("ena_support"),
"uefi_support": data.get("uefi_support"),
"billing_codes": AmiBillingCodes._from_data(
data.get("billing_codes") or {}
),
Expand Down
5 changes: 5 additions & 0 deletions src/pushsource/_impl/schema/staged-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ definitions:
- boolean
- "null"

uefi_support:
type:
- boolean
- "null"

billing_codes:
$ref: "#/definitions/ami_billing_codes"

Expand Down
1 change: 1 addition & 0 deletions tests/baseline/cases/staged-simple-ami-bc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ items:
sriov_net_support: simple
state: PENDING
type: access
uefi_support: null
usage_instructions: fake usage instructions
user_name: Fake-Username
version_title: Fake-Version-Title
Expand Down
52 changes: 52 additions & 0 deletions tests/baseline/cases/staged-simple-ami-uefi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# A pushsource library testcase.
#
# This file was generated from a template.
# To regenerate, run test_baseline.py with PUSHSOURCE_UPDATE_BASELINE=1.

# URL of Source to test.
url: "staged:{{ src_dir }}/tests/staged/data/simple_ami_with_uefi"

# Push items generated from above.
items:
- AmiPushItem:
billing_codes: null
build: null
build_info: null
description: A sample image for testing
dest:
- dest1
ena_support: true
image_id: null
marketplace_entity_type: null
md5sum: null
name: fake-image.raw
origin: {{ src_dir }}/tests/staged/data/simple_ami_with_uefi
public_image: true
recommended_instance_type: null
region: cn-north-1
release:
arch: x86_64
base_product: null
base_version: null
date: 2020-05-11
product: Fake-Product
respin: 1
type: ga
variant: Fake-Variant
version: Fake-Version
release_notes: null
root_device: /dev/sda1
scanning_port: null
security_groups: []
sha256sum: null
signing_key: null
src: {{ src_dir }}/tests/staged/data/simple_ami_with_uefi/dest1/AWS_IMAGES/fake-image.raw
sriov_net_support: simple
state: PENDING
type: access
uefi_support: true
usage_instructions: null
user_name: null
version_title: null
virtualization: hvm
volume: gp2
1 change: 1 addition & 0 deletions tests/baseline/cases/staged-simple-ami.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ items:
sriov_net_support: simple
state: PENDING
type: access
uefi_support: null
rohanpm marked this conversation as resolved.
Show resolved Hide resolved
usage_instructions: null
user_name: null
version_title: null
Expand Down
1 change: 1 addition & 0 deletions tests/staged/data/simple_ami/staged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ payload:
root_device: /dev/sda1
sriov_net_support: simple
type: access
uefi_support: null
virtualization: hvm
volume: gp2
public_image: true
1 change: 1 addition & 0 deletions tests/staged/data/simple_ami_with_bc/staged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ payload:
root_device: /dev/sda1
sriov_net_support: simple
type: access
uefi_support: null
virtualization: hvm
volume: gp2
billing_codes:
Expand Down
Empty file.
27 changes: 27 additions & 0 deletions tests/staged/data/simple_ami_with_uefi/staged.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
header:
version: "0.2"

payload:
files:
- relative_path: dest1/AWS_IMAGES/fake-image.raw
attributes:
description: "A sample image for testing"
ena_support: true
region: cn-north-1
release:
arch: x86_64
base_product: null
base_version: null
date: "20200511"
product: Fake-Product
respin: 1
type: ga
variant: Fake-Variant
version: Fake-Version
root_device: /dev/sda1
sriov_net_support: simple
type: access
uefi_support: true
virtualization: hvm
volume: gp2
public_image: true
Loading