首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gcloud nodejs cloudbuild.yaml陷入死循环

gcloud nodejs cloudbuild.yaml陷入死循环
EN

Stack Overflow用户
提问于 2020-10-04 08:02:26
回答 1查看 457关注 0票数 0

我有一个node.js网站,当我用node server.js在本地运行它时,它运行得很好。我正在尝试使用GCP在线部署它。我创建了一个项目,启用了应用引擎API,并为我的'@cloudbuild.gserviceaccount.com‘账户提供了应用引擎部署者角色权限。

我还在我的存储库中添加了一个cloudbuild.yaml文件:

代码语言:javascript
复制
steps:
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy"]

现在,如果我运行gcloud app deploy,我的构建会被触发,但似乎会导致构建的无限循环?例如,启动我的构建日志如下所示(当前未运行任何内容):

我运行gcloud app deploy,它开始一个新的构建(1a19d9ba):

但是这个构建的某些东西一直在触发新的构建吗?在我本地的计算机终端中,我运行gcloud app deploy得到的输出不断触发新的构建:

代码语言:javascript
复制
$ gcloud app deploy
Services to deploy:

descriptor:      [/mnt/c/Users/marti/Documents/projects/martinbarker/app.yaml]
source:          [/mnt/c/Users/marti/Documents/projects/martinbarker]
target project:  [martinbarker2]
target service:  [default]
target version:  [20201003t165547]
target url:      [https://martinbarker2.wl.r.appspot.com]


Do you want to continue (Y/n)?  y

Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [1a19dxxxxx627d].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/1axxx
------------------------------------------------- REMOTE BUILD OUTPUT --------------------------------------------------starting build "1a19xxxxxx27d"

FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx47:latest#160xxx288
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx547:latest#16xxx88...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:

descriptor:      [/workspace/app.yaml]
source:          [/workspace]
target project:  [martinbarker2]
target service:  [default]
target version:  [20201003t235749]
target url:      [https://martinbarker2.wl.r.appspot.com]


Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [d0d0xxx9a987].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/d0d0xxx987?project=114941087848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "d0d0dxxx987"

FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20201xxx49:latest#160176947xx11
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.20xxx:latest#16xxx548211...
\ [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:

descriptor:      [/workspace/app.yaml]
source:          [/workspace]
target project:  [martinbarker2]
target service:  [default]
target version:  [20201003t235818]
target url:      [https://martinbarker2.wl.r.appspot.com]


Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [683bb8cxxx0368f36].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/683bxxxf36?project=114xx48
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "683bb8xx368f36"

FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020xxx18:latest#16xxx376
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx18:latest#16xx376...
| [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:

descriptor:      [/workspace/app.yaml]
source:          [/workspace]
target project:  [martinbarker2]
target service:  [default]
target version:  [20201003t235843]
target url:      [https://martinbarker2.wl.r.appspot.com]


Do you want to continue (Y/n)?
WARNING: Unable to verify that the Appengine Flexible API is enabled for project [martinbarker2]. You may not have permission to list enabled services on this project. If it is not enabled, this may cause problems in running your deployment. Please ask the project owner to ensure that the Appengine Flexible API has been enabled and that this account has permission to list enabled APIs.
Beginning deployment of service [default]...
Building and pushing image for service [default]
Started cloud build [feecxxx3cd86].
To see logs in the Cloud Console: https://console.cloud.google.com/cloud-build/builds/feexxx87848
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "feec9xxxx3cd86"

FETCHSOURCE
Fetching storage object: gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.2020100xxx082
Copying gs://staging.martinbarker2.appspot.com/us.gcr.io/martinbarker2/appengine/default.202xxx82...
- [1 files][117.7 MiB/117.7 MiB]
Operation completed over 1 objects/117.7 MiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/gcloud
Services to deploy:

descriptor:      [/workspace/app.yaml]
source:          [/workspace]
target project:  [martinbarker2]
target service:  [default]
target version:  [20201003t235909]
target url:      [https://martinbarker2.wl.r.appspot.com]
Do you want to continue (Y/n)?

这样继续下去,现在我有了更多的构建:

我的app.yaml:

代码语言:javascript
复制
runtime: custom
env: flex
manual_scaling:
  instances: 2

是不是我的cloudbuild.yaml文件有问题?我的文件夹中没有dockerfile

EN

回答 1

Stack Overflow用户

发布于 2020-10-05 15:33:35

“这不是一个bug,而是一个特性!”但是它没有记录,或者我找不到它在哪里!实际上,使用App Engine Flex自定义运行时,您将创建一个容器。您可以定义一个cloudbuild.yaml文件或一个Dockerfile来描述容器的创建。这个容器是用Cloud Build创建的。

对于信息,如果您设置了特定的语言运行时,Buildpack用于创建容器,仍然在Cloud Build上;但是不再需要Dockerfile

因此,在您的案例中,正如您所描述的,您有一个部署App Engine flex自定义运行时的cloudbuild.yaml文件,它调用云构建来构建容器,其中的cloudbuild.yaml文件包含在部署的参数中……(循环!)

现在,如何解决这个问题?2个解决方案

  • cloudbuild.yaml文件的名称更改为与此默认命名不匹配(例如cloudbuild-noloop.yaml)。在触发器配置或gcloud builds submit --config=cloudbuild-noloop.yaml command
  • Update your cloudbuild.yaml deploy步骤中设置此名称,如以下

所示

代码语言:javascript
复制
steps:
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy","--ignore-file=cloudbuild.yaml"]
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64190045

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档