Search code examples
google-app-enginebuildfetchtimeoutruntime

Cloud Build fails with timeout when build starts with Fetch instead of Pre-Build Pack.How to make Cloud build run from Pre-Build Pack instead of fetch


My gcloud app deploy fails due to timeout during build. After looking at logs, its taking more than 10 min and the App Engine Standard timeout can't be changed. But the previous all my builds went fine and the only change I noticed between successful and failed build logs are:

  1. failed build is using and fetching the source and images from gae_runtime Pulling image: asia.gcr.io/gae-runtimes/utilities/buildpack-shim:base_20211020a_18_04_RC00
  2. successful build is fetching the image from Pulling image: asia.gcr.io/fn-img/utilities/buildpack-shim:base_20211020a_18_04_RC00.

How to make the build to pull these image from fn-img and not gae-runtimes?


Solution

  • It turns out that you can only configure timeouts for App Engine builds if you are using the Flexible environment. You can configure the timeout by using Cloud Build to deploy your App Engine Standard service. As such you could avoid the 10 minutes timeout limit.

    In this documentation page there is a step by step guide on how to do it but basically the key step is this one:

    In the args field, invoke the gcloud app deploy command and set a timeout for App Engine to use when it invokes Cloud Build. This is required because Cloud Build build steps and builds have a default timeout of 10 minutes and App Engine deployments could take longer than that to complete. Specifying a longer timeout will make sure that the build doesn't timeout if gcloud app deploy takes longer than 10 minutes to complete.

    steps:
    - name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
      entrypoint: 'bash'
      args: ['-c', 'gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy']
    timeout: '1600s'
    

    On the other hand, the App Engine standard environment does not allow the build timeout to be configured. If you're using Cloud Build for deploying on the App Engine standard environment, and your build is failing with a timeout error, consider using the App Engine flexible environment or Cloud Run instead of the App Engine standard environment.