Google Cloud Function 无法部署到新区域

Google Cloud Function failed to deploy to new region

我有一个 python 云函数,最初部署到 us-central1。尝试将此功能部署到 us-east4 时,我在加载代码时收到以下错误:

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.

这是我的代码中报错的行

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

我在部署期间传入了 REGION 环境变量。 运行 与 us-central1 相同的部署命令没有问题。这些部署之间没有任何代码更改。

在 requirements.txt 中升级 google-auth 和 google-auth-httplib2 库解决了这个问题。