Michele
Michele

Reputation: 113

Google cloud functions python37 with storage trigger won't deploy and won't give any logs

I tried deploying with gcloud from the terminal, and I tried via the UI, I get the same error during deployment (build works) in the deployment logs:

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

And gcloud tells me the following:

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.

So, I go to the logs and nothing, nada, nisba. Not a line. Tried upping RAM to 2GB, tried packaging .py files that reside at the same level of main.py out of the root, no luck. Clearly, if locally I call the handler function in main.py from a test script, running it in a virtualenv (py37) with packages from requirements.txt, it works. Running it locally with the functions-framework? It works.

This following is how I'm calling gcloud to deploy so far:

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

Upvotes: 2

Views: 826

Answers (1)

Egor B Eremeev
Egor B Eremeev

Reputation: 1062

Currently GCF is affected by this issue:

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)

Workarounds available before short term fix has been released:

  • Pin the version of the yarl dependency explicitly in the requirements.txt file for your Python37 source code, like

    # requirements.txt
    yarl==1.4.2
    
  • Another alternative is to use the Python 3.8 beta runtime ( which uses a newer / upgraded build procedure that does not require holding onto preinstalled packages / libraries ) and as such this issue should not be prevalent on the Python 3.8 runtime: https://cloud.google.com/functions/docs/concepts/python-runtime

Upvotes: 5

Related Questions