Skip to content

Commit

Permalink
apacheGH-39212: [Release] Retry download binary subprocess in case of…
Browse files Browse the repository at this point in the history
… OpenSSL error (apache#39213)

### Rationale for this change

In case of OpenSSL error when trying to download RC binaries we do not retry and we are facing some issues with artifactory that after some job retries allowed us to successfully download the binaries.

### What changes are included in this PR?

Retry mechanism in case of subprocess error.

### Are these changes tested?

Tested locally verifying wheels and jars for 14.0.2 RC 3.

### Are there any user-facing changes?

No
* Closes: apache#39212

Lead-authored-by: Raúl Cumplido <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
raulcd and kou authored Dec 18, 2024
1 parent 37eb3b5 commit b655852
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions dev/release/download_rc_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,29 @@ def _download_url(self, url, dest_path, *, extra_args=None):
dest_path,
url,
]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
if proc.returncode != 0:
try:
# Don't leave possibly partial file around
os.remove(dest_path)
except IOError:
pass
raise Exception(f"Downloading {url} failed\n"
f"stdout: {stdout}\nstderr: {stderr}")
# Retry subprocess in case it fails with OpenSSL Connection errors
# https://issues.apache.org/jira/browse/INFRA-25274
for attempt in range(5):
if attempt > 0:
delay = attempt * 3
print(f"Waiting {delay} seconds before retrying {url}")
time.sleep(delay)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
if proc.returncode != 0:
try:
# Don't leave possibly partial file around
os.remove(dest_path)
except IOError:
pass
if "OpenSSL" not in stderr:
# We assume curl has already retried on other errors.
break
else:
return
raise Exception(f"Downloading {url} failed\n"
f"stdout: {stdout}\nstderr: {stderr}")

def _curl_version(self):
cmd = ["curl", "--version"]
Expand Down

0 comments on commit b655852

Please sign in to comment.