GCP Cloud build ignores timeout settings

旧时模样 提交于 2021-01-27 14:15:53

问题


I use Cloud Build for copying the configuration file from storage and deploying the app to App Engine flex. The problem is that the build fails every time when it lasts more than 10 minutes. I've specified timeout in my cloudbuild.yaml but it looks like it's ignored. Also, I configured app/cloud_build_timeout and set it to 1000. Could somebody explain to me what is wrong here?

My cloudbuild.yaml looks in this way:

steps:
  - name: gcr.io/cloud-builders/gsutil
    args: ["cp", "gs://myproj-dev-247118.appspot.com/.env.cloud", ".env"]
  - name: "gcr.io/cloud-builders/gcloud"
    args: ["app", "deploy"]
    timeout: 1000s
timeout: 1600s

My app.yaml use custom env that build it from Dockerfile and looks like this:

runtime: custom
env: flex

manual_scaling:
  instances: 1
env_variables:
  NODE_ENV: dev

Dockerfile also contains nothing special, just installing dependencies and app building:

FROM node:10 as front-builder
WORKDIR /app
COPY front-end .
RUN npm install
RUN npm run build:web

FROM node:12
WORKDIR /app
COPY api .
RUN npm install
RUN npm run build
COPY .env .env
EXPOSE 8080
COPY --from=front-builder /app/web-build web-build
CMD npm start

回答1:


When running gcloud app deploy directly for an App Engine Flex app, from your local machine for example, under the hood it spawns a Cloud Build job to build the image that is then deployed to GAE (you can see that build in Cloud Console > Cloud Build). This build has a 10min timeout that can be customized via:

gcloud config set app/cloud_build_timeout 1000

Now, the issue here is that you're issuing the gcloud app deploy command from within Cloud Build itself. Since each individual Cloud Build step is running in its own Docker container, you can't just add a previous step to customize the timeout since the next one will use the default gcloud setting.

You've got several options to solve this:

  • Add a build step to first build the image with docker build, upload it to Google Cloud Registry. You can set a custom timeout on these steps to fit your needs. Finally, deploy your app with glcoud app deploy --image-url=IMAGE-URL.
  • Create your own custom gcloud builder where app/cloud_build_timeout is set to your custom value. You can derive it from the default gcloud builder Dockerfile and add /builder/google-cloud-sdk/bin/gcloud config set app/cloud_build_timeout 1000


来源:https://stackoverflow.com/questions/60431732/gcp-cloud-build-ignores-timeout-settings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!