google-cloud-platformgoogle-cloud-functionsgoogle-cloud-endpointsgoogle-cloud-rungoogle-cloud-endpoints-v2

Google Cloud Functions + Endpoints via ESPv2: Problem with timeout


I have various Cloud Functions which are accessable via Google Endpoints for Cloud Functions. I followed more or less this guide: https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions. This sets up an ESPv2 instance in Google Cloud Run. So far it is working.

Problems arise with one long running cloud function. If the request runs for more than approx. 30 seconds, it is terminated. The API then returns a 504 error code.

The Cloud Run Logs show the following entry:

The request has been terminated because it has reached the maximum request timeout. To change this limit, see https://cloud.google.com/run/docs/configuring/request-timeout

The referenced documentation explains how to configure the Cloud Run Service Timout. There I already had a much higher timeout:

spec:
  timeoutSeconds: 900

The function itself completes without error. So I guess the problem must lie within Endpoints or Cloud Run.

Troubleshooting responses documentation isn't helpful. First I think it is only for ESPv1 (and I can't find something similar explicitly for v2) and it doesn't mention a 504 response at all.

Is it possible that I have to configure the Envoy server directly? How would I do this? Is there something else I am missing to configure timeouts?


Solution

  • I think that is not a problem on Cloud Run (where the max timeout is 900s and not 300 (default on Cloud Run, and 600 is the max for PubSub)).

    So Cloud Endpoint have a timeout. but it's documented at 15s, not 30, strange... So you can override it with the deadline parameter on your x-google-backend definition