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

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml #1287

Conversation

hstastna
Copy link

@hstastna hstastna commented May 2, 2023

📝 Description

Fixes:
https://bugzilla.redhat.com/show_bug.cgi?id=2181920

This is a followup of #1236 introducing the change that efi: { secureBoot: false } was written to VM's yaml when changing Boot mode field value to "UEFI", because that was correct representation of "UEFI" boot mode (secure boot disabled).

In this PR, the following remaining issues are fixed:

  • for existing VM:
    • it shows "UEFI" for Boot mode field in Details for efi: {} in the yaml's bootloader section
  • in Create VM wizard:
    • it shows "UEFI" for Boot mode in Review and create VirtualMachine screen for efi: {} in the yaml's bootloader section
  • for existing template:
    • it shows "UEFI" for Boot mode in Details for efi: {} in the yaml's bootloader section
    • after changing Boot mode value to "UEFI", efi: {} occurs in the yaml (this doesn't happen for existing VMs or when creating a VM)

Part of this PR is also a bit of refactoring - removing duplicated code for updating the VM with selected boot mode data.
The result of refactoring is new updatedVMBootMode function that returns the updated VM object.

Expected results:
The correct value in the yaml after selecting UEFI should be efi: { secureBoot: false }. Also for efi: {} in the YAML (as many default templates come with this), secure boot is enabled and "UEFI (secure)" should be displayed in Boot mode field in the UI.

Notes about the moot modes:
Both efi: {} and efi: { secureBoot: true } in the yaml are equivalent (at least now, maybe this will change) and refer to secure boot enabled displayed as "UEFI (secure)" option in the UI. If no efi present, then "BIOS" is displayed as a boot mode, in the Details tab. This was the original implementation at least. I was not dealing with this third option too much, the main problem was the secure boot option, that was enabled while the UI showed just "UEFI".

How to reproduce the bug:
#1236 (comment)

Note:
It is possible this issue will be fixed by backend eventually, probably the way that efi: {} in the yaml won't represent secure boot anymore (but it's possible they will come up with something else). But till then, we need this PR to make this work as expected.

🎥 Screenshots

Example of a VM yaml:
vm_yaml

Before:
"UEFI" is displayed for Boot mode field in VM Details for efi: {} (see the yaml example above):
vm_before
After changing Boot mode value to "UEFI", efi: {} occurs in the VM Template's yaml:
template_before

After:
"UEFI (secure)" is displayed for Boot mode field in VM Details for efi: {} as expected:
vm_after
After changing Boot mode value to "UEFI", efi: { secureBoot: false } occurs in the VM Template's yaml:
template_after

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 2, 2023

@hstastna: This pull request references Bugzilla bug 2181920, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.14.0) matches configured target release for branch (4.14.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @gouyang

In response to this:

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci openshift-ci bot requested review from gouyang, metalice and yaacov May 2, 2023 16:59
@openshift-ci openshift-ci bot added the approved This issue is something we want to fix label May 2, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 2, 2023

@hstastna: This pull request references Bugzilla bug 2181920, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.14.0) matches configured target release for branch (4.14.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @gouyang

In response to this:

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 2, 2023

@hstastna: This pull request references Bugzilla bug 2181920, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.14.0) matches configured target release for branch (4.14.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @gouyang

In response to this:

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hstastna
Copy link
Author

hstastna commented May 2, 2023

@avivtur @metalice @pcbailey @upalatucci @vojtechszocs please review

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 2, 2023

@hstastna: This pull request references Bugzilla bug 2181920, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.14.0) matches configured target release for branch (4.14.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @gouyang

In response to this:

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.


import { BootloaderOptionValue } from './constants';

export const isObjectEmpty = (obj: object): boolean => isEmpty(obj) && obj !== undefined;
Copy link
Member

Choose a reason for hiding this comment

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

What about case null? Is possible? i think isEmpty(obj) && obj can work also?

Copy link
Author

Choose a reason for hiding this comment

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

In the place I am using this function, null isn't possible. But if someone decided to use this somewhere else, probably isEmpty(obj) && obj is better to use.

Copy link
Member

Choose a reason for hiding this comment

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

Can you explain to me why just isEmpty(obj) is not enough? it should return true if it's either one of these:
null / undefind / [] / {} / ''

Copy link
Author

@hstastna hstastna May 3, 2023

Choose a reason for hiding this comment

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

Because we don't want to receive true if the object is null or undefined. We want to end up here in case of null or undefined. And if vm?.spec?.template?.spec?.domain?.firmware?.bootloader?.efi is equal to {}, it means secure boot enabled..

Copy link
Member

@avivtur avivtur May 3, 2023

Choose a reason for hiding this comment

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

so efi: {} and efi: { secureBoot: true } are equivalent right? and if efi does not exist we want bios?

Copy link
Author

@hstastna hstastna May 3, 2023

Choose a reason for hiding this comment

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

Yes, they both refer to secure boot enabled displayed as "UEFI (secure)" option in the UI. And yes, if no efi, then show "BIOS". This was the original implementation at least. I was not dealing with this third option too much, the main problem was the secure boot option. I've just added this to the description of the PR to avoid future confusions.

@hstastna
Copy link
Author

hstastna commented May 3, 2023

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 3, 2023

@hstastna: This pull request references Bugzilla bug 2181920, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.14.0) matches configured target release for branch (4.14.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @gouyang

In response to this:

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

1 similar comment
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 3, 2023

@hstastna: This pull request references Bugzilla bug 2181920, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.14.0) matches configured target release for branch (4.14.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @gouyang

In response to this:

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hstastna hstastna force-pushed the BZ_SecureBoot_is_always_enabled_for_UEFI_VMs_No2 branch 2 times, most recently from 2b8c089 to ced3fd7 Compare May 3, 2023 16:31
@hstastna hstastna requested review from avivtur and metalice May 3, 2023 16:31
Copy link
Member

@avivtur avivtur left a comment

Choose a reason for hiding this comment

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

looks good just one nit and I think it's good to go

vmDraft.spec.template.spec.domain.features.smm = { enabled: true };

switch (firmwareBootloader) {
case 'uefi':
Copy link
Member

Choose a reason for hiding this comment

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

can you please add these hard-coded constants into a constants file? uefi eufiSecure ..

Copy link
Author

Choose a reason for hiding this comment

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

Seems that I am doing more refactoring in this PR than bug fixing ...

@hstastna hstastna force-pushed the BZ_SecureBoot_is_always_enabled_for_UEFI_VMs_No2 branch 3 times, most recently from 712263c to 520a507 Compare May 8, 2023 17:15
@hstastna hstastna requested a review from avivtur May 8, 2023 17:15
This is a followup of kubevirt-ui#1236
introducing the change that "efi: { secureBoot: false }" was written to
VM's yaml when changing Boot mode field value to "UEFI", because that
was correct representation of "UEFI" boot mode (secure boot disabled).

In this commit, the following remaining issues are fixed:

- for existing VM:
-- it shows "UEFI" for Boot mode field in Details for "efi: {}" in the
yaml's bootloader section

- in Create VM wizard:
-- it shows "UEFI" for Boot mode field in Review and create
VirtualMachine screen for "efi: {}" in the yaml's bootloader section

- for existing template:
-- it shows "UEFI" for Boot mode field in Details for "efi: {}" in the
yaml's bootloader section
-- after changing Boot mode field to "UEFI", "efi: {}" occurs in the
yaml (this doesn't happen for existing VMs or when creating a VM)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2181920
@hstastna hstastna force-pushed the BZ_SecureBoot_is_always_enabled_for_UEFI_VMs_No2 branch from 520a507 to 4316e3e Compare May 8, 2023 17:27
@openshift-ci openshift-ci bot added the lgtm Passed code review, ready for merge label May 9, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 9, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: avivtur, hstastna

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 8f25f08 into kubevirt-ui:main May 9, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented May 9, 2023

@hstastna: All pull requests linked via external trackers have merged:

Bugzilla bug 2181920 has been moved to the MODIFIED state.

In response to this:

Bug 2181920: Display "UEFI" for Boot mode for "efi: {}" in yaml

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This issue is something we want to fix bugzilla/severity-unspecified bugzilla/valid-bug lgtm Passed code review, ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants