gcloud nodejs cloudbuild.yaml陷入无限循环 [英] gcloud nodejs cloudbuild.yaml stuck in infinite loop
问题描述
我有一个node.js网站,当我使用node server.js
在本地运行它时,它运行良好.我正在尝试通过GCP在线部署它.我创建了一个项目,启用了应用引擎API,并为我的'@ cloudbuild.gserviceaccount.com'帐户授予了应用引擎部署者角色权限.
I have a node.js website that runs fine when I run it locally with node server.js
. I'm trying to deploy it online with GCP. I created a project, enabled app engine API, and gave my '@cloudbuild.gserviceaccount.com' account app engine deployer role permissions.
我还在我的仓库中添加了一个cloudbuild.yaml文件:
I also added a cloudbuild.yaml file to my repo:
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy"]
现在,如果我运行gcloud app deploy
,我的构建会被触发,但对我来说会引起无限的构建循环?例如,开始构建日志如下所示(当前未运行):
Now If I run gcloud app deploy
, my build gets triggered, but appears to me causing an infinite loop of builds? For example, starting out my build log looks like this (nothing currently running):
我运行gcloud app deploy
并开始新的构建(1a19d9ba):
i run gcloud app deploy
and it begins a new build (1a19d9ba):
但是此版本的某些内容会不断触发新版本吗?在我的本地计算机终端中,我得到的用于运行gcloud app deploy
的输出将不断触发新的构建:
But something with this build keeps triggering new builds? in my local computer terminal, the output I get for running gcloud app deploy
keeps triggering new builds:
$ 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)?
这种情况还在继续,现在我有更多的构建:
This goes on, and now I have many more builds:
我的app.yaml:
My app.yaml:
runtime: custom
env: flex
manual_scaling:
instances: 2
我的cloudbuild.yaml文件是否有问题?我的文件夹中没有dockerfile
is it something with my cloudbuild.yaml file? I dont have a dockerfile in my folder
推荐答案
"这不是错误;这是一个功能!"但这没有记录,或者我没有找到!实际上,使用App Engine Flex自定义运行时,您将创建一个容器.您可以定义cloudbuild.yaml
文件或Dockerfile
来描述容器的创建.并且此容器是使用Cloud Build创建的.
"It's not a bug; it's a feature!" But it's not documented, or I didn't find where! Actually, with App Engine Flex custom runtime, you will create a container. You can define either a cloudbuild.yaml
file or a Dockerfile
to describe the container creation. And this container is created with Cloud Build.
有关信息,如果您设置了特定的语言运行时,则使用Buildpack来创建容器,该容器仍在Cloud Build上.但是不再需要Dockerfile
因此,按照您的描述,您有一个cloudbuild.yaml
文件,该文件部署了App Engine flex自定义运行时,该文件调用Cloud Build来构建容器,其中的cloudbuild.yaml
文件包含已部署的参数. ....(循环!)
So, in your case, as you describe, you have a cloudbuild.yaml
file that deploys an App Engine flex custom runtime, that call a Cloud Build to build the container, with the cloudbuild.yaml
file in parameters that deploys..... (loop!)
好,现在如何解决此问题? 2个解决方案
- 更改
cloudbuild.yaml
文件的名称,使其与此默认命名不匹配(例如,cloudbuild-noloop.yaml
).在触发器配置或gcloud builds submit --config=cloudbuild-noloop.yaml
命令 中设置此名称
- 像这样更新您的
cloudbuild.yaml
部署步骤
- Change the name of your
cloudbuild.yaml
file to not match this default naming (cloudbuild-noloop.yaml
for example). Set this name in the trigger configuration or in thegcloud builds submit --config=cloudbuild-noloop.yaml
command - Update your
cloudbuild.yaml
deploy step like this
steps:
- name: "gcr.io/cloud-builders/gcloud"
args: ["app", "deploy","--ignore-file=cloudbuild.yaml"]
这篇关于gcloud nodejs cloudbuild.yaml陷入无限循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!