allow install script to print error on failed binary download #11335
+15
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Currently, when the install script encounters an error downloading a file (either the binary signature or the binary itself), the script either exits with no error message or continues running until the missing file causes another error. This is confusing to the user because it is unclear where or why the script failed. This change fixes the bug and allows the error message to print before exiting.
Types of Changes
Bugfix
Verification
For the positive case, the script should continue with no changes to current functionality.
For the negative case, run the script with a condition that will cause the hash or binary download to fail. For example, I set the
INSTALL_K3S_VERSION
variable to something that does not exist:Which should now log something like this, whereas the error message would not show previously:
Testing
No, if there are integration tests for
install.sh
please point me in that direction so I can make the update.Linked Issues
Fixes #1774
User-Facing Change
Further Comments
When logging
$?
after the case statement, the result was blank rather than holding the return code for the previous command, which I assume bash interpreted as a 0/success code. This change introduces a$status
variable that explicitly stores the exit code, and also cleans up some of the-e
and+e
logic/adds comments to make sure it is clear why they are being used.This is my first contribution here, and one of my first ever, so please let me know of any additional changes that may need to be made. Thanks!