【问题标题】:Issue deploying to AppEngine (Flex) from Cloud Build从 Cloud Build 部署到 AppEngine (Flex) 的问题
【发布时间】:2020-03-22 18:30:24
【问题描述】:

我在通过 Cloud Build 部署到 AppEngine Flex Env​​ironment 时遇到问题。它以前工作得很好,但今天不行。这是 Cloud Build 日志中显示的跟踪信息。

... (skipped composer's things) ...
Step #1 Updating service [legacy-api] (this may take several minutes)...
Step #1: ..............................................................................................................................................................................................................................................................................................failed.
Step #1: ERROR: (gcloud.app.deploy) Error Response: [13] Flex operation projects/MY-PROJECT/regions/asia-east2/operations/... error [INTERNAL]: An internal error occurred while processing task /appengine-flex-v1/insert_flex_deployment/flex_create_resources>2019-11-27T07:24:52.924Z46964.jo.8: Deployment Manager operation …/operation-… errors: [code: "RESOURCE_ERROR"
Step #1: location: "/deployments/…/resources/…-00it"
Step #1: message: "{\"ResourceType\":\"compute.v1.instanceTemplate\",\"ResourceErrorCode\":\"400\",\"ResourceErrorMessage\":{\"code\":400,\"errors\":[{\"domain\":\"global\",\"message\":\"Invalid value for field \'resource.properties.labels\': \'\'. Label value \'Infinity\' violates format constraints. The value can only contain lowercase letters, numeric characters, underscores and dashes. The value can be at most 63 characters long. International characters are allowed.\",\"reason\":\"invalid\"}],\"message\":\"Invalid value for field \'resource.properties.labels\': \'\'. Label value \'Infinity\' violates format constraints. The value can only contain lowercase letters, numeric characters, underscores and dashes. The value can be at most 63 characters long. International characters are allowed.\",\"statusMessage\":\"Bad Request\",\"requestPath\":\"https://compute.googleapis.com/compute/v1/projects/.../global/instanceTemplates\",\"httpMethod\":\"POST\"}}"
Step #1: ] 

这是我的 cloudbuild.yaml

steps:
  - name: 'gcr.io/$PROJECT_ID/secrets:latest'
    entrypoint: sh
    args: 
      - "-c"
      - |
        cat /secrets/$_ENV/environments/${_SERVICE_NAME}.env > .env
  - name: 'gcr.io/cloud-builders/gcloud'
    args: ["app", "deploy", "--version=$SHORT_SHA", "--promote", "--stop-previous-version", "./app.yaml"]
timeout: 1200s

substitutions:
  _ENV: staging
  _SERVICE_NAME: legacy-api

这是我的 app.yaml

service: legacy-api
runtime: php
env: flex

runtime_config:
  document_root: public
  enable_stackdriver_integration: true

resources:
  cpu: 4
  memory_gb: 8

beta_settings:
    cloud_sql_instances: ${CLOUD_SQL_INSTANCE}

network:
  name: default

现在,这阻止了我的开发过程。请帮忙。

提前致谢!

编辑 2019-11-27 23:00 GMT+0700(问题首次出现后 12 小时)

事情变得更糟,我不知道该怎么办。然后,我尝试将部署目标更改为标准环境。这就是我得到的。

Starting Step #1
Step #1: Already have image (with digest): gcr.io/cloud-builders/gcloud
Step #1: Services to deploy:
Step #1: 
Step #1: descriptor:      [/workspace/app.yaml]
Step #1: source:          [/workspace]
Step #1: target project:  [....]
Step #1: target service:  [legacy-api-std]
Step #1: target version:  [201911272240]
Step #1: target url:      [https://legacy-api-std-dot-....appspot.com]
Step #1: 
Step #1: 
Step #1: Do you want to continue (Y/n)?  
Step #1: Beginning deployment of service [legacy-api-std]...
Step #1: Created .gcloudignore file. See `gcloud topic gcloudignore` for details.
Step #1: #============================================================#
Step #1: #= Uploading 1 file to Google Cloud Storage                 =#
Step #1: #============================================================#
Step #1: File upload done.
Step #1: ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: This deployment has too many files. New versions are limited to 10000 files for this app.
Step #1: - '@type': type.googleapis.com/google.rpc.BadRequest
Step #1:   fieldViolations:
Step #1:   - description: This deployment has too many files. New versions are limited to 10000
Step #1:       files for this app.
Step #1:     field: version.deployment.files[...]
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/cloud-builders/gcloud" failed: exit status 1

更新 2019-11-28 08:40:00+0700(距问题首次出现已近 24 小时

8 小时前在 Google Cloud 支持中打开的案例

这里仍然没有奇迹

【问题讨论】:

  • 这里的错误非常简单,它说“部署管理器操作”失败,因为"Invalid value for field \'resource.properties.labels\': \'\'. Label value \'Infinity\' violates format constraints. 您应该仔细检查,将标签从“无限”更改为“无限”将消除错误。另外,在这里添加您的部署方式将很高兴,因为我猜您可能正在使用部署管理器来执行此操作?
  • 感谢您的回答,我不知道部署管理器是什么以及它是如何工作的。我所拥有的就是我在上面发布的。顺便说一句,它曾经完美地工作到昨天。任何想法? :(
  • 您的.env 文件中有标签吗?个人认为没有。这个标签似乎是谷歌自动的东西,我不知道从哪里来。特别是如果它直到最近才有效,您应该向支持人员打开一个案例并询问他们是否没有可以阻止您当前部署的新版本。
  • 如果您能提供一些关于 cloudbuild.yaml 中第一步的背景知识也会很好。图像 'gcr.io/$PROJECT_ID/secrets:latest' 有什么?只是将一些数据复制到 .env 文件中?
  • @guillaumeblaquiere 在我的.env 中没有类似LABEL 的东西。我应该寻找其他名称吗?

标签: google-app-engine google-cloud-platform google-cloud-build


【解决方案1】:

我发现这个问题在 GCP 中是已知的,团队目前正在解决这个问题。

错误是由于您使用的 SHORT_SHA 与内部部署管理器 YAML 解析器使用的正则表达式之一匹配。目前,这个已知问题是由于传递了一个 SHA 字符串,Deployment Manager YAML 解析器将评估为浮点数而不是字符串,将时间戳作为值传递也会导致解析器错误地将字符串评估为时间戳。

然后在 SHORT_SHA 的末尾添加一个随机字符串将强制它成为一个字符串,从而避免该问题:

"${SHORT_SHA}xyz"

可以找到用于浮点数的正则表达式here

我还创建了这个PIT 来跟踪工程师的调查。有关它的更多信息将在此线程中分享。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-14
    • 2021-07-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-14
    相关资源
    最近更新 更多