Skip to content

Commit

Permalink
Add timeout for s3 download (#27386)
Browse files Browse the repository at this point in the history
* Add timeout for s3 download
* Add the comments about lifetime
  • Loading branch information
atuchin-m authored Jan 31, 2025
1 parent 3a145ae commit d8d340c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tools/perf/components/cloud_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@


class CloudFolder(str, Enum):
TEST_PROFILES = 'perf-profiles'
CATAPULT_PERF_DATA = 'telemetry-perf-data'
TEST_PROFILES = 'perf-profiles' # 6 months lifetime
CATAPULT_PERF_DATA = 'telemetry-perf-data' # infinite lifetime


def UpdateSha1(path: str):
Expand All @@ -40,7 +40,7 @@ def UploadFileToCloudStorage(folder: CloudFolder, path: str):

s3_url = f's3://{_CLOUD_BUCKET}/{folder}/{sha1}'
success, _ = perf_test_utils.GetProcessOutput(
['aws', 's3', 'cp', path, s3_url, '--sse', 'AES256'])
['aws', 's3', 'cp', path, s3_url, '--sse', 'AES256'], timeout=10 * 60)
if not success:
raise RuntimeError(f'Can\'t upload to {s3_url}')
return path + '.sha1'
4 changes: 2 additions & 2 deletions tools/perf/components/perf_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ def GetProcessOutput(args: List[str],
return False, e.output


def DownloadFile(url: str, output: str):
def DownloadFile(url: str, output: str, timeout_sec=3 * 60):

def load_data():
for _ in range(3):
try:
logging.info('Downloading %s to %s', url, output)
f = urlopen(url)
f = urlopen(url, timeout=timeout_sec)
return f.read()
except Exception:
logging.error('Download attempt failed')
Expand Down

0 comments on commit d8d340c

Please sign in to comment.