-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 onie image install's platform verification #8814
Conversation
Based on #8542. |
installer/x86_64/install.sh
Outdated
@@ -92,6 +92,39 @@ VAR_LOG_SIZE=4096 | |||
|
|||
[ -r platforms/$onie_platform ] && . platforms/$onie_platform | |||
|
|||
# Verify image platform is inside devices list | |||
# Temporarily set TIMEOUT as 10 seconds | |||
if [ "$install_env" = "onie" ] && [ -d devices ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be an option among sonic/onie/build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have sonic_installer to block wrong platform already. It might be tedious if user input --skip-platform-check and be prompted here the second time to confirm install.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable. Could you change sonic-utilities code with same logic, checking platform_asic instead of previous image asic.
Or, we could unify the logic here, so my comment will be finally applicable.
build_image.sh
Outdated
{ | ||
# Generate asic-specific ONIE device list | ||
rm -rf ./installer/x86_64/devices/ | ||
mkdir -p ./installer/x86_64/devices/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just need to create an empty file in this folder. No need to remove directory. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generate_onie_installer_image
I am following the above code to refresh the folder every time. And the folder needs to be created the first time.
installer/x86_64/install.sh
Outdated
if [ "$install_env" = "onie" ] && [ "$machine" != "generic" ]; then | ||
if ! grep -Fxq "$onie_platform" devices/platforms_asic; then | ||
INPUT_TIMEOUT=10 | ||
echo "The image you're trying to install is of a different platform as the running platform" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change
installer/x86_64/install.sh
Outdated
if [ "$install_env" = "onie" ] && [ "$machine" != "generic" ]; then | ||
if ! grep -Fxq "$onie_platform" devices/platforms_asic; then | ||
INPUT_TIMEOUT=10 | ||
echo "The image you're trying to install is of a different platform as the running platform" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will change
installer/x86_64/install.sh
Outdated
INPUT_TIMEOUT=10 | ||
echo "The image you're trying to install is of a different platform as the running platform" | ||
while true; do | ||
read -t $INPUT_TIMEOUT -r -p "Do you still wish to install this image? [y/n]: " input |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually there is no requirement to timeout. If the script is used by automation, the prompt will be enough to break the normal path (The automation will have its own timeout).
If the script is used by user, it is too rush for them to response in 10 seconds, and without any hint. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will remove it
build_image.sh
Outdated
cp ./installer/x86_64/devices/platforms_asic .platforms_asic | ||
zip -g $OUTPUT_ABOOT_IMAGE .platforms_asic | ||
rm .platforms_asic | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implement a new function generate_aboot_device_list
? If some logic is common, you can extract into another function like generate_device_list
. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
build_image.sh
Outdated
mkdir -p ./installer/x86_64/devices/ | ||
for d in `find -L ./device -maxdepth 2 -mindepth 2 -type d`; do | ||
if [ -f $d/platform_asic ] && grep -Fxq "$CONFIGURED_PLATFORM" $d/platform_asic; then | ||
echo "${d##*/}" >> ./installer/x86_64/devices/platforms_asic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to be merged. |
build_image.sh
Outdated
@@ -170,6 +184,13 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then | |||
zip -g $ABOOT_BOOT_IMAGE version | |||
rm version | |||
|
|||
generate_device_list ".platforms_asic" | |||
# Check file existence in case of general build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the file doesn't exist in some case. For example, if the TARGET_MACHINE was set to 'general', it won't match any platform_asic. I will bypass the check here.
build_image.sh
Outdated
local platforms_asic=$1 | ||
for d in `find -L ./device -maxdepth 2 -mindepth 2 -type d`; do | ||
if [ -f $d/platform_asic ] && grep -Fxq "$CONFIGURED_PLATFORM" $d/platform_asic; then | ||
echo "${d##*/}" >> "$platforms_asic"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of general build, sonic installer verification would bypass because $platforms_asic file is not there. But if it is a empty file, it will fail because no platform is in the file. I guess general build means we could install it to any asic.
CONFIGURED_PLATFORM is general by default.
Check out here. general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the generic
fix!
Still:
clean the file at the begining in case the file is not empty. No need to rm before this function call.
If there is no platforms using CONFIGURED_PLATFORM asic, this function should generated an empty file.
Proposed code
# Generate asic-specific device list
generate_device_list()
{
local platforms_asic=$1
# Create an empty function, and later append to it
echo -n > "$platforms_asic"
for d in `find -L ./device -maxdepth 2 -mindepth 2 -type d`; do
if [ -f $d/platform_asic ]; then
if [ "$CONFIGURED_PLATFORM" = "generic" ] || grep -Fxq "$CONFIGURED_PLATFORM" $d/platform_asic; then
echo "${d##*/}" >> "$platforms_asic";
fi;
fi;
done
}
Otherwise, you need add rm .platforms_asic
in the aboot branch, which is actually best cleaned inside this function.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
2. resolve comment
@wen587 is there a way to bypass this check (or respond to it) in automation, e.g. if it's hit in a Jenkins run? |
If you are using |
This reverts commit ba2968d.
Depends on #8542. Please DO NOT MERGE before it
Why I did it
Provide onie image install verification
How I did it
Add devices folder based on platform_asic and check if current platform inside the list
How to verify it
In onie env, install a bin file which differs the running platform's ASIC. For example;
install sonic-broadcom.bin to mellanox ASIC platform
install sonic-vs.bin to broadcom ASIC platform
Which release branch to backport (provide reason below if selected)
Description for the changelog
A picture of a cute animal (not mandatory but encouraged)