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

Improve error message in update.sh when updater is corrupt. #2766

Merged
merged 3 commits into from
Aug 18, 2021

Conversation

winder
Copy link
Contributor

@winder winder commented Aug 18, 2021

Summary

A user reported a strange and not very helpful error message. This was due to incomplete error handling in the bash script relating to a truncated updater binary.

The current workaround for this is to delete the updater binary and trigger update.sh to re-download it, but this is not obvious and I wouldn't expect any user to reach that conclusion.

This fix adds error handling in case updater fails and should fix this particular failure.

Here is the error message:

Current Version = 8590458880
Latest Version =
./update.sh: line 250: [: 8590458880: unary operator expected
New version found
Update Downloaded to /tmp/tmp.QlV71NLGFr/.tar.gz
Expanding update...
tar (child): /tmp/tmp.QlV71NLGFr/.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
*** UPDATE FAILED: Error expanding update ***

Test Plan

Ran some tests against a directory, empty file, and regular file in my shell:

will@arendelle:~/go/src/github.com/algorand/go-algorand/cmd/updater$ [[ -f dir && -s dir ]]
will@arendelle:~/go/src/github.com/algorand/go-algorand/cmd/updater$ echo $?
1
will@arendelle:~/go/src/github.com/algorand/go-algorand/cmd/updater$ [[ -f empty && -s empty ]]
will@arendelle:~/go/src/github.com/algorand/go-algorand/cmd/updater$ echo $?
1
will@arendelle:~/go/src/github.com/algorand/go-algorand/cmd/updater$ [[ -f util.go && -s util.go ]]
will@arendelle:~/go/src/github.com/algorand/go-algorand/cmd/updater$ echo $?
0

@codecov-commenter
Copy link

codecov-commenter commented Aug 18, 2021

Codecov Report

Merging #2766 (ad3640b) into master (80bd5ed) will decrease coverage by 0.03%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2766      +/-   ##
==========================================
- Coverage   47.14%   47.10%   -0.04%     
==========================================
  Files         349      349              
  Lines       56322    56322              
==========================================
- Hits        26553    26531      -22     
- Misses      26800    26818      +18     
- Partials     2969     2973       +4     
Impacted Files Coverage Δ
ledger/roundlru.go 90.56% <0.00%> (-5.67%) ⬇️
network/wsPeer.go 72.14% <0.00%> (-2.79%) ⬇️
agreement/cryptoVerifier.go 75.73% <0.00%> (-2.21%) ⬇️
agreement/proposalManager.go 96.07% <0.00%> (-1.97%) ⬇️
data/transactions/verify/txn.go 45.08% <0.00%> (-0.90%) ⬇️
catchup/service.go 69.35% <0.00%> (-0.78%) ⬇️
ledger/acctupdates.go 62.55% <0.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 80bd5ed...ad3640b. Read the comment docs.

# check if the updater binary exist.
if [ -f "${SCRIPTPATH}/updater" ]; then
# check if the updater binary exist and is not empty.
if [[ -s "${SCRIPTPATH}/updater" && -f "${SCRIPTPATH}/updater" ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

could you please check this line with shellcheck ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shellcheck doesn't have anything to say about this line

@tsachiherman tsachiherman merged commit 2baca4f into algorand:master Aug 18, 2021
@winder winder deleted the will/update-script branch August 19, 2021 00:18
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.

None yet

3 participants