Skip to content

Commit 509312f

Browse files
Encode PUT data before sending POST request to Codecov (#144)
When testing ATS in the sentry fork I have 3 out of 5 uploads timing out when pushing to storage. I noticed that we are generating the PUT payload *after* receiving the response from Codecov. Generating PUT payload includes compressing the report file, that might be pretty big, and considering that the pre-signed put URL has a TTL of 10s this time might be influential. So now we are just prepping the data completely before starting the upload process, in the hopes that this will save us enough time to get all uploads into storage in time.
1 parent 6bfcd84 commit 509312f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

codecov_cli/services/upload/upload_sender.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,20 @@ def send_upload_data(
4646
"job_code": job_code,
4747
}
4848

49+
# Data to upload to Codecov
4950
headers = get_token_header_or_fail(token)
5051
encoded_slug = encode_slug(slug)
5152
url = f"https://api.codecov.io/upload/{git_service}/{encoded_slug}/commits/{commit_sha}/reports/{report_code}/uploads"
52-
resp = send_post_request(url=url, data=data, headers=headers)
53-
54-
if resp.status_code >= 400:
55-
return resp
53+
# Data that goes to storage
54+
reports_payload = self._generate_payload(upload_data, env_vars)
5655

57-
resp_json_obj = json.loads(resp.text)
56+
resp_from_codecov = send_post_request(url=url, data=data, headers=headers)
57+
if resp_from_codecov.status_code >= 400:
58+
return resp_from_codecov
59+
resp_json_obj = json.loads(resp_from_codecov.text)
5860
put_url = resp_json_obj["raw_upload_location"]
59-
reports_payload = self._generate_payload(upload_data, env_vars)
60-
resp = send_put_request(put_url, data=reports_payload)
61-
return resp
61+
resp_from_storage = send_put_request(put_url, data=reports_payload)
62+
return resp_from_storage
6263

6364
def _generate_payload(
6465
self, upload_data: UploadCollectionResult, env_vars: typing.Dict[str, str]

0 commit comments

Comments
 (0)