mirror of https://github.com/apache/lucene.git
LUCENE-8106: Handle IncompleteRead exceptions while downloading the Jenkins log by retrying a limited number of times
This commit is contained in:
parent
04120273f8
commit
0c61c857c8
|
@ -18,6 +18,7 @@ import os
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
@ -95,7 +96,7 @@ def run(cmd, rememberFailure=True):
|
|||
lastFailureCode = code
|
||||
return code
|
||||
|
||||
def fetchAndParseJenkinsLog(url):
|
||||
def fetchAndParseJenkinsLog(url, numRetries):
|
||||
global revisionFromLog
|
||||
global branchFromLog
|
||||
global antOptions
|
||||
|
@ -127,11 +128,19 @@ def fetchAndParseJenkinsLog(url):
|
|||
print('[repro] Ant options: %s' % antOptions)
|
||||
except urllib.error.URLError as e:
|
||||
raise RuntimeError('ERROR: fetching %s : %s' % (url, e))
|
||||
|
||||
except http.client.IncompleteRead as e:
|
||||
if numRetries > 0:
|
||||
print('[repro] Encountered IncompleteRead exception, pausing and then retrying...')
|
||||
time.sleep(2) # pause for 2 seconds
|
||||
return fetchAndParseJenkinsLog(url, numRetries - 1)
|
||||
else:
|
||||
print('[repro] Encountered IncompleteRead exception, aborting after too many retries.')
|
||||
raise RuntimeError('ERROR: fetching %s : %s' % (url, e))
|
||||
|
||||
if revisionFromLog == None:
|
||||
if reJenkinsURLWithoutConsoleText.match(url):
|
||||
print('[repro] Not a Jenkins log. Appending "/consoleText" and retrying ...\n')
|
||||
fetchAndParseJenkinsLog(url + '/consoleText')
|
||||
return fetchAndParseJenkinsLog(url + '/consoleText', numRetries)
|
||||
else:
|
||||
raise RuntimeError('ERROR: %s does not appear to be a Jenkins log.' % url)
|
||||
if 0 == len(tests):
|
||||
|
@ -223,7 +232,7 @@ def getLocalGitBranch():
|
|||
|
||||
def main():
|
||||
config = readConfig()
|
||||
tests = fetchAndParseJenkinsLog(config.url)
|
||||
tests = fetchAndParseJenkinsLog(config.url, numRetries = 2)
|
||||
if config.useGit:
|
||||
localGitBranch = getLocalGitBranch()
|
||||
|
||||
|
|
Loading…
Reference in New Issue