python - 带有存储触发器的谷歌云函数 python37 将不会部署并且不会提供任何日志

标签 python google-cloud-platform google-cloud-functions

我尝试从终端使用 gcloud 进行部署,并通过 UI 进行尝试,但在部署期间(构建工作),我在部署日志中遇到了相同的错误:

Error: function terminated. Recommended action: inspect logs for termination reason. Function cannot be initialized.

gcloud 告诉我以下内容:

ERROR: (gcloud.functions.deploy) OperationError: code=13, message=Function deployment failed due to a health check failure. This usually indicates that your code was built successfully but failed during a test execution. Examine the logs to determine the cause. Try deploying again in a few minutes if it appears to be transient.

所以,我查看了日志,但什么也没有,nada,nisba。不是一条线。尝试将 RAM 增加到 2GB,尝试将与 main.py 位于同一级别的 .py 文件打包到根目录之外,但没有成功。 显然,如果我在本地从测试脚本调用 main.py 中的处理程序函数,并在 virtualenv (py37) 中使用requirements.txt 中的包运行它,它就可以工作。使用函数框架在本地运行它?它有效。

以下是我迄今为止调用 gcloud 进行部署的方式:

gcloud functions deploy load_to_bigquery \
  --project=project-platform-dev \
  --region europe-west1 \
  --runtime python37 \
  --memory 1024MB \
  --entry-point handler \
  --env-vars-file .env.dev.yaml \
  --trigger-resource the-source-bucket \
  --trigger-event google.storage.object.finalize

最佳答案

目前 GCF 受此问题影响:

GCF Python37 function deployment fails due to broken external aiohttp/yarl dependency

A few customers have reported Python3.7 / Python3.8 Cloud functions deployments failing for their functions with the following error messages:

Python3.7 Runtime: Function failed on loading user code.

" Function deployment failed due to a health check failure. This usually indicates that your code was built successfully but failed during a test execution. Examine the logs to determine the cause. Try deploying again in a few minutes if it appears to be transient. "

There are no errors visible in Stackdriver logs in the customer (user) project, however internally we do receive a stack trace against the Functions Python37 runtime environment library included for an issue with one of its dependencies.

The aiohttp library utilized within our GCF Python37 runtime, uses the yarl dependency and the root cause of this issue is a bad release of the yarl library)

短期修复发布之前可用的解决方法:

  • 在中显式固定 yarl 依赖项的版本 Python37 源代码的requirements.txt 文件,例如

    # requirements.txt
    yarl==1.4.2
    
  • 另一种选择是使用 Python 3.8 beta 运行时( 使用更新/升级的构建过程,不需要持有 到预安装的软件包/库上),因此这个问题应该 在 Python 3.8 上不流行 运行时间:https://cloud.google.com/functions/docs/concepts/python-runtime

关于python - 带有存储触发器的谷歌云函数 python37 将不会部署并且不会提供任何日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63577067/

相关文章:

python - 在 numpy 中停止自动舍入

tensorflow - keras模型转tpu模型的方法

python - 我如何使用GAE听Google表格然后运行一组python代码?

google-cloud-platform - Google Cloud 函数执行时间和限制

javascript - 向 onCreate 用户 firebase 云函数添加自定义声明

python - 将 NLTK 与 Google App Engine 结合使用

python - python中的复杂解析

python - Intellisense 不适用于 Visual Studio Code 中的 Unreal

apache-spark - 数据管道 - 从网络驱动器读取数据的最佳方法

Node.js 将图像上传到 firebase 存储