@@ -366,8 +366,8 @@ def generate_cloud_function_code(
366
366
def create_cloud_function (
367
367
self ,
368
368
def_ ,
369
- cf_name ,
370
369
* ,
370
+ random_name ,
371
371
input_types : Tuple [str ],
372
372
output_type : str ,
373
373
package_requirements = None ,
@@ -428,9 +428,9 @@ def create_cloud_function(
428
428
create_function_request .parent = (
429
429
self .get_cloud_function_fully_qualified_parent ()
430
430
)
431
- create_function_request .function_id = cf_name
431
+ create_function_request .function_id = random_name
432
432
function = functions_v2 .Function ()
433
- function .name = self .get_cloud_function_fully_qualified_name (cf_name )
433
+ function .name = self .get_cloud_function_fully_qualified_name (random_name )
434
434
function .build_config = functions_v2 .BuildConfig ()
435
435
function .build_config .runtime = python_version
436
436
function .build_config .entry_point = entry_point
@@ -497,24 +497,25 @@ def create_cloud_function(
497
497
# Cleanup
498
498
os .remove (archive_path )
499
499
except google .api_core .exceptions .AlreadyExists :
500
- # If a cloud function with the same name already exists, let's
501
- # update it
502
- update_function_request = functions_v2 .UpdateFunctionRequest ()
503
- update_function_request .function = function
504
- operation = self ._cloud_functions_client .update_function (
505
- request = update_function_request
506
- )
507
- operation .result ()
500
+ # b/437124912: The most likely scenario is that
501
+ # `create_function` had a retry due to a network issue. The
502
+ # retried request then fails because the first call actually
503
+ # succeeded, but we didn't get the successful response back.
504
+ #
505
+ # Since the function name was randomly chosen to avoid
506
+ # conflicts, we know the AlreadyExist can only happen because
507
+ # we created it. This error is safe to ignore.
508
+ pass
508
509
509
510
# Fetch the endpoint of the just created function
510
- endpoint = self .get_cloud_function_endpoint (cf_name )
511
+ endpoint = self .get_cloud_function_endpoint (random_name )
511
512
if not endpoint :
512
513
raise bf_formatting .create_exception_with_feedback_link (
513
514
ValueError , "Couldn't fetch the http endpoint."
514
515
)
515
516
516
517
logger .info (
517
- f"Successfully created cloud function { cf_name } with uri ({ endpoint } )"
518
+ f"Successfully created cloud function { random_name } with uri ({ endpoint } )"
518
519
)
519
520
return endpoint
520
521
@@ -571,7 +572,7 @@ def provision_bq_remote_function(
571
572
if not cf_endpoint :
572
573
cf_endpoint = self .create_cloud_function (
573
574
def_ ,
574
- cloud_function_name ,
575
+ random_name = cloud_function_name ,
575
576
input_types = input_types ,
576
577
output_type = output_type ,
577
578
package_requirements = package_requirements ,
0 commit comments