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

Support to verify reboot for secure boot #979

Merged
merged 14 commits into from
Jul 13, 2020
Merged

Conversation

xumia
Copy link
Collaborator

@xumia xumia commented Jul 9, 2020

- What I did
Add a command "sonic_installer verify_reboot" to verify the image before reboot.
The command will be called when reboot/fast-reboot/warm-reboot.

- How I did it

- How to verify it

- Previous command output (if the output of a command-line utility has changed)

- New command output (if the output of a command-line utility has changed)

@qiluo-msft
Copy link
Contributor

qiluo-msft commented Jul 9, 2020

@Staphylo Could you please help review ? #Closed

Comment on lines 480 to 481
@cli.command('verify_reboot')
def verify_reboot():
Copy link
Contributor

Choose a reason for hiding this comment

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

Along with Qi's comment above, this command should also be named form clearly, e.g., verify-next-image.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@qiluo-msft
Copy link
Contributor

    subprocess.call(['rm','-rf', os.path.join(HOST_PATH, image_dir)])

Seem you function get_image_path is useful for many use cases. Could you refactor thoroughly?


Refers to: sonic_installer/bootloader/aboot.py:115 in 3a374f3. [](commit_id = 3a374f3, deletion_comment = False)

if not super(AbootBootloader, self).verify_reboot():
return False
image = self.get_next_image()
image_path = self.get_image_path(image) + '/sonic.swi'
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 9, 2020

Choose a reason for hiding this comment

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

sonic.swi [](start = 52, length = 9)

Magic string in aboot.py #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

and os.path.join

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

debug "Next image ${NEXT_SONIC_IMAGE} doesn't exist ..."
exit ${EXIT_NEXT_IMAGE_NOT_EXISTS}
# Verify reboot by sonic_installer
local message=$(sonic_installer verify-reboot)
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 9, 2020

Choose a reason for hiding this comment

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

message [](start = 10, length = 7)

Did you only capture stdout but stderr? #Closed

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added the stderr message.

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comments

if not super(AbootBootloader, self).verify_reboot():
return False
image = self.get_next_image()
image_path = self.get_image_path(image) + '/sonic.swi'
Copy link
Contributor

Choose a reason for hiding this comment

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

and os.path.join

sonic_installer/bootloader/bootloader.py Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Jul 10, 2020

This pull request introduces 2 alerts when merging b10af37 into 1b992b3 - view on LGTM.com

new alerts:

  • 2 for Syntax error

@lgtm-com
Copy link

lgtm-com bot commented Jul 10, 2020

This pull request introduces 1 alert when merging db0a9d2 into 1b992b3 - view on LGTM.com

new alerts:

  • 1 for Unused import

qiluo-msft
qiluo-msft previously approved these changes Jul 10, 2020
scripts/fast-reboot Outdated Show resolved Hide resolved
scripts/reboot Outdated Show resolved Hide resolved
sonic_installer/main.py Outdated Show resolved Hide resolved
Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

Add new comment

@lgtm-com
Copy link

lgtm-com bot commented Jul 10, 2020

This pull request introduces 1 alert when merging 7914998 into 1b992b3 - view on LGTM.com

new alerts:

  • 1 for Unused import

@xumia
Copy link
Collaborator Author

xumia commented Jul 10, 2020

retest default please

qiluo-msft
qiluo-msft previously approved these changes Jul 10, 2020
exit ${EXIT_NEXT_IMAGE_NOT_EXISTS}
# Verify the next image by sonic_installer
local message=$(sonic_installer verify_next_image 2>&1)
if [ $? -ne 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

This part of the reboot script is executed under -e option, meaning that the failure will trigger script to exit. Please take examples in the script to catch error code.

Copy link
Collaborator Author

@xumia xumia Jul 11, 2020

Choose a reason for hiding this comment

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

Thanks, the command can be simplified, fixed. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

If you simplified this way, the sonic_installer verify-next-image will only output Failed or Done, which has no context in fast-reboot output.

As Ying suggested: Please take examples in the script to catch error code.

Your original debug command is still useful.


In reply to: 453135626 [](ancestors = 453135626)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks Qi, fixed.

Copy link
Contributor

@qiluo-msft qiluo-msft Jul 12, 2020

Choose a reason for hiding this comment

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

Thanks @yxieca actually #Closed

qiluo-msft
qiluo-msft previously approved these changes Jul 12, 2020
sonic_installer/main.py Outdated Show resolved Hide resolved
sonic_installer/main.py Outdated Show resolved Hide resolved
@xumia xumia merged commit b4b5fd3 into sonic-net:master Jul 13, 2020
jleveque added a commit that referenced this pull request Jul 19, 2020
#995)

Root group name was changed from `cli` to `sonic_installer` in #983. However, `verify-next-image` subcommand was being added in an already-open PR #979 at the time. It did not get updated before merge. This aligns it with the new group name.
stepanblyschak pushed a commit to stepanblyschak/sonic-utilities that referenced this pull request Apr 18, 2022
#### Why I did it
To pick up fixes from submodule sonic-sairedis which include the following fixes:
```
commit 1027eef3a331e84560827c7584ee8009baf434d5 (HEAD -> 202012, origin/202012)
Author: gechiang <62408185+gechiang@users.noreply.github.com>
Date:   Wed Dec 8 03:13:34 2021 -0800

    [202012] Prevent other notification event storms to keep enqueue unchecked and drained all memory that leads to crashing the switch router (sonic-net#976)

commit 94455e50d3444dcd60093b7a39c7f427337a94d2
Author: VenkatCisco <77468614+VenkatCisco@users.noreply.github.com>
Date:   Tue Jun 15 03:23:20 2021 -0700

    Add cisco-8000 checks to syncd_init_common (sonic-net#839)

commit 2df539483ed68519c3c9c6df958d3ed2f31dd629
Author: Kamil Cudnik <kcudnik@gmail.com>
Date:   Mon Dec 6 20:50:23 2021 +0100

    [lgtm] Add gmock libs to lgtm (sonic-net#979)

```
malletvapid23 added a commit to malletvapid23/Sonic-Utility that referenced this pull request Aug 3, 2023
…d (#995)

Root group name was changed from `cli` to `sonic_installer` in sonic-net/sonic-utilities#983. However, `verify-next-image` subcommand was being added in an already-open PR sonic-net/sonic-utilities#979 at the time. It did not get updated before merge. This aligns it with the new group name.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants