【问题标题】:gcloud nodejs cloudbuild.yaml stuck in infinite loopgcloud nodejs cloudbuild.yaml陷入无限循环
【发布时间】:2021-01-19 05:20:37
【问题描述】:

当我使用 node server.js 在本地运行它时,我有一个运行良好的 node.js 网站。我正在尝试使用 GCP 在线部署它。我创建了一个项目,启用了应用引擎 API,并授予了我的“@cloudbuild.gserviceaccount.com”帐户应用引擎部署者角色权限。

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

steps:
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy"]

现在如果我运行 gcloud app deploy ,我的构建会被触发,但在我看来会导致构建的无限循环?例如,开始我的构建日志看起来像这样(当前没有运行):

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

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

$ 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:

runtime: custom
env: flex
manual_scaling:
  instances: 2

这与我的 cloudbuild.yaml 文件有关吗?我的文件夹中没有 dockerfile

【问题讨论】:

  • 你能分享你的app.yaml吗?
  • K 我将它添加到我的问题中。我以这种方式设置它以尝试使网站保持在线状态,因为过去我遇到过一个问题,即我的网站在一段时间未使用后会离线,然后下一个使用它的人会导致该网站重新启动,并且该人的连接速度很慢。

标签: node.js google-app-engine google-cloud-platform gcloud


【解决方案1】:

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

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

因此,在您的情况下,正如您所描述的,您有一个部署 App Engine flex 自定义运行时的 cloudbuild.yaml 文件,该文件调用 Cloud Build 来构建容器,并在部署的参数中使用 cloudbuild.yaml 文件。 ....(循环!)

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

  • cloudbuild.yaml 文件的名称更改为与此默认命名不匹配(例如cloudbuild-noloop.yaml)。在触发器配置或gcloud builds submit --config=cloudbuild-noloop.yaml 命令中设置此名称
  • 像这样更新您的 cloudbuild.yaml 部署步骤
steps:
- name: "gcr.io/cloud-builders/gcloud"
  args: ["app", "deploy","--ignore-file=cloudbuild.yaml"]

【讨论】:

  • 尝试了这两种解决方案,但都没有工作请帮忙!!
猜你喜欢
  • 2018-08-25
  • 2020-05-13
  • 1970-01-01
  • 2013-03-17
  • 2021-02-15
  • 2022-01-23
相关资源
最近更新 更多