gaoyunhaii commented on a change in pull request #10951: [FLINK-15701][Travis] 
Retries when uploading to transfer.sh fails
URL: https://github.com/apache/flink/pull/10951#discussion_r370973068
 
 

 ##########
 File path: tools/travis_watchdog.sh
 ##########
 @@ -132,8 +135,23 @@ upload_artifacts_s3() {
        fi
 
        # upload to https://transfer.sh
-       echo "Uploading to transfer.sh"
-       curl --upload-file $ARTIFACTS_FILE --max-time 60 https://transfer.sh
+       echo "Uploading to transfer.sh, maximum retries is 
${TRANSFER_UPLOAD_MAX_RETRIES}"
+       for i in $(seq 1 ${TRANSFER_UPLOAD_MAX_RETRIES});do
+               url_or_error=$(curl --upload-file $ARTIFACTS_FILE --max-time 60 
https://transfer.sh)
+               echo ${url_or_error}
+
+               if grep -q "^http" <<< ${url_or_error};then
+                       # Check if the uploaded file can be accessed 
successfully
+                       access_response=$(curl --max-time 60 -o /dev/null -w 
"%{http_code}" -H "Accept: text/html" ${url_or_error} 2>/dev/null)
+                       if [[ "$access_response" = "200" ]];then
+                               break
+                       fi
+               fi
+
+               if [[ "$i" -lt "$TRANSFER_UPLOAD_MAX_RETRIES" ]];then
+                       echo "Failed to upload to transfer.sh and will retry..."
+               fi
+       done
 
 Review comment:
   According to curl's man page, the native retry mechanism should works for 
response code 4xx or 500 used by transfer.sh (according to [the server's source 
code](https://github.com/dutchcoders/transfer.sh/blob/2e33f7c7163c9b804e626a5f9ffc0b24b1510ca2/server/handlers.go)
 and the observation yesterday for failed uploading) , and it will be simpler. 
Have updated the PR accordingly. Very thanks for the tips. 👍  

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to