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

Retry signing if it fails #3558

Merged
merged 1 commit into from
Jun 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 25 additions & 11 deletions tools/taskcluster/sign_apk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import os
import subprocess
import sys
import time

v1_platforms = {
'oculusvr3dofstore',
Expand Down Expand Up @@ -72,13 +73,30 @@ def main(name, argv):
print "Target ", target
cmd = ["curl", "-F", "input=@" + apk, "-o", target, "-H", "Authorization: " + cred, sign_url]

try:
print subprocess.check_output(cmd)
except subprocess.CalledProcessError as err:
cmd = ' '.join(err.cmd).replace(cred, "XXX")
print "Signing apk failed:", cmd
print "Output:", err.output
sys.exit(err.returncode)
signTryCount = 0
done = False
while not done and signTryCount < 5:
if signTryCount > 0:
print "Waiting 5 seconds before trying to sign apk again..."
time.sleep(5)
signTryCount = signTryCount + 1
try:
print subprocess.check_output(cmd)
except subprocess.CalledProcessError as err:
cleanCmd = ' '.join(err.cmd).replace(cred, "XXX")
print "Signing apk failed:", cleanCmd
print "Output:", err.output
continue
fileinfo = subprocess.check_output(['file', target])
if fileinfo.find("ASCII text") != -1:
print 'Error returned from autograph:'
print subprocess.check_output(['cat', target])
else:
done = True

if not done:
print "Failed to sign apk after multiple tries"
sys.exit(2)

if align:
split = os.path.splitext(target)
Expand All @@ -91,10 +109,6 @@ def main(name, argv):
print subprocess.check_output(['apksigner', 'verify', '--verbose', target])
except subprocess.CalledProcessError as err:
print "Verifying apk failed"
fileinfo = subprocess.check_output(['file', target])
if fileinfo.find("ASCII text") != -1:
print 'Error returned from autograph:'
print subprocess.check_output(['cat', target])
sys.exit(err.returncode)
print "Archiving", target
os.rename(target, artifacts_path + "/" + os.path.basename(target))
Expand Down