Search code examples
google-cloud-platformgoogle-cloud-functionsgoogle-cloud-dataproc

Google Cloud Function failed to deploy to new region


I have a python cloud function that was initially deployed to us-central1. When trying to deploy this function to us-east4 I get the following error when my code is being loaded:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. This is likely due to a bug in the user code. Error message: with_scopes_if_required() got an unexpected keyword argument 'default_scopes'
Detailed stack trace:
Traceback (most recent call last):
  File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py", line 359, in check_or_load_user_function
    _function_handler.load_user_function()
  File "/env/local/lib/python3.7/site-packages/google/cloud/functions/worker_v2.py", line 236, in load_user_function
    spec.loader.exec_module(main_module)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/user_code/main.py", line 20, in <module>
    client_options={'api_endpoint': '{}-dataproc.googleapis.com:443'.format(REGION)})
  File "/env/local/lib/python3.7/site-packages/google/cloud/dataproc_v1/services/workflow_template_service/client.py", line 244, in __init__
    quota_project_id=client_options.quota_project_id,
  File "/env/local/lib/python3.7/site-packages/google/cloud/dataproc_v1/services/workflow_template_service/transports/grpc.py", line 134, in __init__
    quota_project_id=quota_project_id,
  File "/env/local/lib/python3.7/site-packages/google/cloud/dataproc_v1/services/workflow_template_service/transports/grpc.py", line 190, in create_channel
    **kwargs
  File "/env/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 311, in create_channel
    default_host=default_host,
  File "/env/local/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 238, in _create_composite_credentials
    default_scopes=default_scopes
TypeError: with_scopes_if_required() got an unexpected keyword argument 'default_scopes'
. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.

This is the line in my code that the error is complaining about

DATAPROC_WORFLOW_CLIENT = dataproc_v1.WorkflowTemplateServiceClient(
    client_options={'api_endpoint': '{}-dataproc.googleapis.com:443'.format(REGION)})

I am passing in the REGION env variable during the deploy. Running the same deploy command with us-central1 there are no issues. There hasn't been any code changes between these deployments.


Solution

  • Upgrading the google-auth and google-auth-httplib2 libraries in requirements.txt fixed the issue.