Skip to content

Commit 1ea3e07

Browse files
Remove unnecessary check for UUID collision (#4445)
This should speed up preprocess for fuzz task.
1 parent 48b8858 commit 1ea3e07

File tree

1 file changed

+4
-12
lines changed
  • src/clusterfuzz/_internal/google_cloud_utils

1 file changed

+4
-12
lines changed

src/clusterfuzz/_internal/google_cloud_utils/storage.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,24 +1396,16 @@ def get_arbitrary_signed_upload_urls(remote_directory: str,
13961396
num_uploads: int) -> List[str]:
13971397
"""Returns |num_uploads| number of signed upload URLs to upload files with
13981398
unique arbitrary names to remote_directory."""
1399-
# We verify there are no collisions for uuid4s in CF because it would be bad
1400-
# if there is a collision and in most cases it's cheap (and because we
1401-
# probably didn't understand the likelihood of this happening when we started,
1402-
# see https://stackoverflow.com/a/24876263). It is not cheap if we had to do
1403-
# this 10,000 times. Instead create a prefix filename and check that no file
1404-
# has that name. Then the arbitrary names will all use that prefix.
1399+
# We don't verify there are no collisions for uuid4s because it's extremely
1400+
# unlikely, takes time, and it's basically benign if it happens (it
1401+
# won't) since we will just clobber some other corpus uploads from
1402+
# the same day.
14051403
unique_id = uuid.uuid4()
14061404
base_name = unique_id.hex
14071405
if not remote_directory.endswith('/'):
14081406
remote_directory = remote_directory + '/'
14091407
# The remote_directory ends with slash.
14101408
base_path = f'{remote_directory}{base_name}'
1411-
base_search_path = f'{base_path}*'
1412-
if exists(base_search_path):
1413-
# Raise the error and let retry go again. There is a vanishingly small
1414-
# chance that we get more collisions. This is vulnerable to races, but is
1415-
# probably unneeded anyway.
1416-
raise ValueError(f'UUID collision found {str(unique_id)}')
14171409

14181410
urls = (f'{base_path}-{idx}' for idx in range(num_uploads))
14191411
logs.info('Signing URLs for arbitrary uploads.')

0 commit comments

Comments
 (0)