Chr*_*aya 3 docker google-container-registry google-cloud-build
我已经设置了一个 Google Cloud Build 管道,它将从 Dockerfile 构建一个 docker 映像、测试该映像并将该映像推送到 Google 容器注册表中。
运行管道后,我注意到所有定义的步骤都通过SUCCESS状态传递,但构建摘要本身返回FAILURE状态,即使我可以看到图像正在生成到 Google 容器注册表中。
我使用以下命令来构建图像
gcloud builds submit --config cloudbuild.yml --gcs-log-dir 'gs://<bucket>' .
Run Code Online (Sandbox Code Playgroud)
下面是返回的错误消息:
ERROR: (gcloud.builds.submit) build www-xxxx-yyyy-zzzz completed with status "FAILURE"
Error: The command exited with status 1
Run Code Online (Sandbox Code Playgroud)
如果所有步骤都标记为 ,是否有任何原因导致gcloud builds submit命令以上述代码退出?1SUCCESS
gcloud builds describe下面是从该特定构建的命令中获取的一些过滤日志数据。
steps:
- args:
- build
- -t
- <host>/<project/<image>:<tag>
- .
name: gcr.io/cloud-builders/docker
status: SUCCESS
- args:
- test
- --image
- <host>/<project/<image>:<tag>
- --config
- test_config.yml
- -o
- json
name: gcr.io/gcp-runtimes/container-structure-test
status: SUCCESS
Run Code Online (Sandbox Code Playgroud)
以下是 Google Cloud Build 设置:
# cloudbuild.yml
steps:
# Build the image
- name: 'gcr.io/cloud-builders/docker'
args: [ 'build', '-t', '<host>/<project/<image>:<tag>', '.' ]
# Test the image
- name: 'gcr.io/gcp-runtimes/container-structure-test'
args: [
'test',
'--image',
'<host>/<project/<image>:<tag>',
'--config',
'test_config.yml',
'-o',
'json'
]
# Push the image
images: [ '<host>/<project/<image>:<tag>' ]
Run Code Online (Sandbox Code Playgroud)
在 Google Cloud 支持团队的帮助下,我终于解决了这个问题。
他们发现一个403 Permission Denied错误,因为Cloud Build容器试图访问Google Cloud Storage以删除存储在存储桶中的某个日志对象,此错误消息是在用户/客户端无法访问的Cloud Build后台系统中发现的。该403 Permission Denied错误是应用到存储桶的对象保留策略的结果。
就我而言,我已将保留策略替换为生命周期策略来解决此问题,并且它有效。我们这样做是因为我们认为控制 Cloud Build 日志大小是我们的主要目标,并且为了防止对日志文件的任何意外删除/修改,我们最终设置了对日志存储桶中资源的只读访问权限,除了Cloud Build 使用的服务帐户。
| 归档时间: |
|
| 查看次数: |
1627 次 |
| 最近记录: |