Switch from infinite retries on upgrade to 10 retries. (#20450)

This changes the flutter tool to just try 10 times before giving up when running "flutter upgrade". Infinite retries can hang bots, and really don't provide a lot of help: if we've failed to upgrade for for nearly a minute, trying every five seconds, then something is just not responding.

Also, changed the bot default warning level to "normal" from "all", because the solver messages are VERY verbose: several megs of output for doing packages get on Flutter. "normal" will give warnings, user messages and errors, which should be sufficient to diagnose problems on the bots without spamming the log.

I removed the retrying for building the snapshot on flutter.bat because we don't do that on the other platforms, and because I can't imagine how running it again would give a different answer.

I also fixed a problem in the whitespace detection when no files matched the type of file that it is looking for, and removed the code that waits until failure to print the logs on setup, since reducing the log output made a huge difference.
This commit is contained in:
Greg Spencer
2018-08-11 19:10:14 -07:00
committed by GitHub
parent cf88359ae4
commit 01d6444490
4 changed files with 50 additions and 39 deletions

View File

@@ -39,6 +39,23 @@ function _rmlock () {
[ -n "$FLUTTER_UPGRADE_LOCK" ] && rm -f "$FLUTTER_UPGRADE_LOCK"
}
function retry_upgrade {
local total_tries="10"
local remaining_tries=$(($total_tries - 1))
while [[ "$remaining_tries" > 0 ]]; do
(cd "$FLUTTER_TOOLS_DIR" && "$PUB" upgrade "$VERBOSITY" --no-packages-dir) && break
echo "Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds... ($remaining_tries tries left)"
remaining_tries=$(($remaining_tries - 1))
sleep 5
done
if [[ "$remaining_tries" == 0 ]]; then
echo "Command 'pub upgrade' still failed after $total_tries tries, giving up."
return 1
fi
return 0
}
function upgrade_flutter () {
mkdir -p "$FLUTTER_ROOT/bin/cache"
@@ -94,7 +111,7 @@ function upgrade_flutter () {
echo Building flutter tool...
if [[ "$CI" == "true" || "$BOT" == "true" || "$CONTINUOUS_INTEGRATION" == "true" || "$CHROME_HEADLESS" == "1" ]]; then
PUB_ENVIRONMENT="$PUB_ENVIRONMENT:flutter_bot"
VERBOSITY="--verbosity=all"
VERBOSITY="--verbosity=normal"
fi
export PUB_ENVIRONMENT="$PUB_ENVIRONMENT:flutter_install"
@@ -102,12 +119,8 @@ function upgrade_flutter () {
export PUB_CACHE="${PUB_CACHE:-"$FLUTTER_ROOT/.pub-cache"}"
fi
while : ; do
cd "$FLUTTER_TOOLS_DIR"
"$PUB" upgrade "$VERBOSITY" --no-packages-dir && break
echo "Error: Unable to 'pub upgrade' flutter tool. Retrying in five seconds..."
sleep 5
done
retry_upgrade
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
echo "$revision" > "$STAMP_PATH"
fi