Skip to content

[fwutil] Add fwutil update all to support the automatic platform component fw updates#1242

Merged
sujinmkang merged 22 commits intosonic-net:masterfrom
sujinmkang:fwutil_rebase
Oct 27, 2021
Merged

[fwutil] Add fwutil update all to support the automatic platform component fw updates#1242
sujinmkang merged 22 commits intosonic-net:masterfrom
sujinmkang:fwutil_rebase

Conversation

@sujinmkang
Copy link
Copy Markdown
Collaborator

@sujinmkang sujinmkang commented Nov 16, 2020

- What I did
Add the support for the automatic platform component fw updates
- How I did it
Add fwutil auto_update interfaces
- How to verify it
Work with dell to verify the auto_update interfaces with ssd firmware update.
- 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)
New added command outputs are available in the following HLD:
sonic-net/SONiC#648

@sujinmkang
Copy link
Copy Markdown
Collaborator Author

@rkdevi27 and @padmanarayana please review this new PR.

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 16, 2020

This pull request introduces 1 alert when merging 6d6633f into f46c27e - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 17, 2020

This pull request introduces 1 alert when merging 53ec476 into 1c45ca1 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 23, 2020

This pull request introduces 2 alerts when merging f4574c9 into f9eb739 - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Wrong number of arguments in a call

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 24, 2020

This pull request introduces 2 alerts when merging 7efd058 into 9dc58ea - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Wrong number of arguments in a call

scripts/reboot Outdated
debug "Handling task file for boot type ${REBOOT_TYPE}”
${DEVPATH}/${PLATFORM}/${PLATFORM_FWUTIL_AU_REBOOT_HANDLE} ${REBOOT_TYPE} || PLATFORM_FW_AU_RC=$?
if [[ $PLATFORM_FW_AU_RC -ne 0 ]]; then
error "Failed to handle the platform firmware auto-update for ${REBOOT_TYPE} Exit code: $PLATFORM_FW_AU_RC"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sujinmkang please double check whether error is available in this context

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 24, 2020

This pull request introduces 2 alerts when merging f29a5b4 into 5b8da56 - view on LGTM.com

new alerts:

  • 1 for Unused import
  • 1 for Wrong number of arguments in a call

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 25, 2020

This pull request introduces 1 alert when merging 15cb89d into 5b8da56 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 27, 2020

This pull request introduces 1 alert when merging a2ac11c into 8f3b22e - view on LGTM.com

new alerts:

  • 1 for Unused import

@sujinmkang
Copy link
Copy Markdown
Collaborator Author

@rkdevi27 @nazariig @padmanarayana can you please help review this PR?

scripts/reboot Outdated
debug "Handling task file for boot type ${REBOOT_TYPE}”
${DEVPATH}/${PLATFORM}/${PLATFORM_FWUTIL_AU_REBOOT_HANDLE} ${REBOOT_TYPE} || PLATFORM_FW_AU_RC=$?
if [[ $PLATFORM_FW_AU_RC -ne 0 ]]; then
debug "Failed to handle the platform firmware auto-update for ${REBOOT_TYPE} Exit code: $PLATFORM_FW_AU_RC"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sujinmkang debug "ERROR: Failed to handle the platform firmware auto-update for ${REBOOT_TYPE} Exit code: $PLATFORM_FW_AU_RC"

debug "Handling task file for boot type ${REBOOT_TYPE}”
${DEVPATH}/${PLATFORM}/${PLATFORM_FWUTIL_AU_REBOOT_HANDLE} ${REBOOT_TYPE} || PLATFORM_FW_AU_RC=$?
if [[ $PLATFORM_FW_AU_RC -ne 0 ]]; then
debug "Failed to handle the platform firmware auto-update for ${REBOOT_TYPE} Exit code: $PLATFORM_FW_AU_RC"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@sujinmkang debug "ERROR: Failed to handle the platform firmware auto-update for ${REBOOT_TYPE} Exit code: $PLATFORM_FW_AU_RC"

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Nov 30, 2020

This pull request introduces 1 alert when merging 393fc18 into a5b78cf - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Apr 22, 2021

This pull request introduces 1 alert when merging 68cdb1e into 59ed6f3 - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Apr 27, 2021

This pull request introduces 1 alert when merging f46a3b4 into 9dba93f - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented May 4, 2021

This pull request introduces 1 alert when merging 228e47f into 9492eab - view on LGTM.com

new alerts:

  • 1 for Unused import

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented May 18, 2021

This pull request introduces 1 alert when merging 4261570 into ad801bf - view on LGTM.com

new alerts:

  • 1 for Unused import

sujinmkang pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Jun 16, 2021
… fwutil auto-update (#7721)

Why I did it
The Mellanox platform is required to support the fwutil auto-update feature defined here

This is to allow switches, when performing SONiC upgrades to choose whether to perform firmware upgrades that may interrupt the data plane through a cold boot.

How I did it
Two methods were added to the component implementations for mellanox.

In the base Component class we add a default function that chooses to skip the installation of any firmware unless the cold boot option is provided. This is because the Mellanox platform, by default, does not support installing firmware on ONIE, the CPLD, or the BIOS "on-the-fly".

In the ComponentSSD class we add a function that behaves similarly but uses the Mellanox specific SSD firmware upgrade tool to check if the current SSD supports being upgraded on the fly in order to decide whether to skip or perform the installation.

How to verify it
Unit tests are included with this PR. These test will run on build of target sonic-mellanox.bin

You may also perform fwutil auto-update ... commands after sonic-net/sonic-utilities#1242 is merged in.
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Jul 2, 2021

This pull request introduces 1 alert when merging da1e4ef into 4818360 - view on LGTM.com

new alerts:

  • 1 for Unused import

carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this pull request Aug 7, 2021
… fwutil auto-update (sonic-net#7721)

Why I did it
The Mellanox platform is required to support the fwutil auto-update feature defined here

This is to allow switches, when performing SONiC upgrades to choose whether to perform firmware upgrades that may interrupt the data plane through a cold boot.

How I did it
Two methods were added to the component implementations for mellanox.

In the base Component class we add a default function that chooses to skip the installation of any firmware unless the cold boot option is provided. This is because the Mellanox platform, by default, does not support installing firmware on ONIE, the CPLD, or the BIOS "on-the-fly".

In the ComponentSSD class we add a function that behaves similarly but uses the Mellanox specific SSD firmware upgrade tool to check if the current SSD supports being upgraded on the fly in order to decide whether to skip or perform the installation.

How to verify it
Unit tests are included with this PR. These test will run on build of target sonic-mellanox.bin

You may also perform fwutil auto-update ... commands after sonic-net/sonic-utilities#1242 is merged in.
@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Aug 22, 2021

This pull request introduces 1 alert when merging dd59bea into cd3ee78 - view on LGTM.com

new alerts:

  • 1 for Unused import

cli_abort(ctx, str(e))


# 'updates' subcommand
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please change it to 'update'

@lgtm-com
Copy link
Copy Markdown

lgtm-com bot commented Aug 31, 2021

This pull request introduces 1 alert when merging 9c6436a into 720b650 - view on LGTM.com

new alerts:

  • 1 for Unused local variable

fwutil/lib.py Outdated
Comment on lines +1038 to +1039
for comp_path, comp_au_status in data.items():
if not self.__is_dict(comp_au_status):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the value for comp_path is a list, please iterate over it seperately.

Suggested change
for comp_path, comp_au_status in data.items():
if not self.__is_dict(comp_au_status):
for comp_path, au_status in data.items():
for comp_au_status in au_status:
if not self.__is_dict(comp_au_status):


comp_au_status['comp'] = component_path
comp_au_status['status'] = status
comp_au_status['info'] = info
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add version details.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@ArunSaravananBalachandran I fixed only the parsing part based on the last HLD update. But the last HLD update is a little gap between the requirement for reboot_handler. I will set up a meeting sometime tomorrow to revise the HLD again.

auto update status should be reset after reboot
…vailable version information from get_available_firmware_version() api
Copy link
Copy Markdown
Contributor

@ArunSaravananBalachandran ArunSaravananBalachandran left a comment

Choose a reason for hiding this comment

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

@sujinmkang, could you please add a check (like below) in reboot_pre_check in the reboot scripts to prevent the reboot if a firmware auto update was scheduled for a different reboot type.

fast-reboot

    # Make sure firmware auto update is not scheduled for a different reboot
    FIRMWARE_AU_STATUS_DIR="/tmp/firmwareupdate"
    FW_AU_TASK_FILE_REGEX="${FIRMWARE_AU_STATUS_DIR}/*_fw_au_task"
    case "$REBOOT_TYPE" in
        "fast-reboot")
            FW_AU_TASK_FILE_EXP="${FIRMWARE_AU_STATUS_DIR}/fast_fw_au_task"
            ;;
        "warm-reboot")
            FW_AU_TASK_FILE_EXP="${FIRMWARE_AU_STATUS_DIR}/warm_fw_au_task"
            ;;
    esac
    FW_AU_TASK_FILE=$(compgen -G ${FW_AU_TASK_FILE_REGEX}) || true
    if [[ -n "${FW_AU_TASK_FILE}" ]] && [[ ! -f "${FW_AU_TASK_FILE_EXP}" ]]; then
        error "Firmware auto update scheduled for a different reboot: ${FW_AU_TASK_FILE}"
        exit "${EXIT_FAILURE}"
    fi

reboot

    # Make sure firmware auto update is not scheduled for a different reboot
    FIRMWARE_AU_STATUS_DIR="/tmp/firmwareupdate"
    FW_AU_TASK_FILE_REGEX="${FIRMWARE_AU_STATUS_DIR}/*_fw_au_task"
    FW_AU_TASK_FILE_EXP="${FIRMWARE_AU_STATUS_DIR}/cold_fw_au_task"
    FW_AU_TASK_FILE=$(compgen -G ${FW_AU_TASK_FILE_REGEX}) || true
    if [[ -n "${FW_AU_TASK_FILE}" ]] && [[ ! -f "${FW_AU_TASK_FILE_EXP}" ]]; then
        VERBOSE=yes debug "Firmware auto update scheduled for a different reboot: ${FW_AU_TASK_FILE}"
        exit 1
    fi

fwutil/lib.py Outdated
Comment on lines +408 to +413
elif len(value1) == 2 and self.VERSION_KEY not in value1:
missing_key = self.VERSION_KEY
break
elif len(value1) == 3 and self.UTILITY_KEY not in value1:
missing_key = self.UTILITY_KEY
break
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As both VERSION_KEY and UTILITY_KEY are optional, please remove these checks since the above will break even if one of them is not present.

fwutil/lib.py Outdated
Comment on lines +370 to +424
if missing_key is not None:
if missing_key is not None and missing_key is not self.UTILITY_KEY and missing_key is not self.VERSION_KEY:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This change can be reverted, once the above checks have been removed.

@sujinmkang sujinmkang changed the title [fwutil] Add fwutil auto_update to support the automatic platform component fw updates [fwutil] Add fwutil update all to support the automatic platform component fw updates Oct 26, 2021
@sujinmkang sujinmkang merged commit 3a8ab73 into sonic-net:master Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants