GCP Cloud构建会忽略超时设置 [英] GCP Cloud build ignores timeout settings

查看:31
本文介绍了GCP Cloud构建会忽略超时设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Cloud Build从存储中复制配置文件,并将应用程序部署到 App Engine flex .问题在于,每次构建持续10分钟以上时,构建都会失败.我在cloudbuild.yaml中指定了超时时间,但似乎已被忽略.另外,我配置了 app/cloud_build_timeout 并将其设置为1000.有人可以向我解释这是什么问题吗?

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?

我的 cloudbuild.yaml 看起来是这样的:

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

我的 app.yaml 使用自定义env,该环境从Dockerfile构建它,如下所示:

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还没有包含任何特殊内容,仅安装了依赖项和应用程序构建:

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

推荐答案

在直接为App Engine Flex应用程序运行 gcloud app deploy 时,例如从本地计算机在引擎盖下生成Cloud Build作业以构建映像,然后将其部署到GAE(您可以在Cloud Console> Cloud Build中看到该版本).此版本的超时时间为10分钟,可以通过以下方式自定义:

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

现在,这里的问题是您是从Cloud Build本身发出 gcloud app deploy 命令.由于每个单独的Cloud Build步骤都在其自己的Docker容器中运行,因此您不能仅添加上一步来自定义超时,因为下一个步骤将使用默认的 gcloud 设置.

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.

您有几种解决方案:

  • 添加一个构建步骤,首先使用 docker build 构建该映像,然后将其上传到Google Cloud Registry.您可以在这些步骤上设置自定义超时以满足您的需求.最后,使用 glcoud app deploy --image-url = IMAGE-URL 部署您的应用.
  • 创建您自己的自定义gcloud构建器其中 app/cloud_build_timeout 设置为您的自定义值.您可以从默认gcloud构建器Dockerfile 派生并添加/builder/google-cloud-sdk/bin/gcloud配置设置应用程序/cloud_build_timeout 1000
  • 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

这篇关于GCP Cloud构建会忽略超时设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆