从 Cloud Build 部署到 AppEngine (Flex) 时出现问题



我遇到了有关通过Cloud Build部署到AppEngine Flex环境的问题。它曾经工作得很好,但今天不行了。这是云构建日志中显示的跟踪。

... (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

这是我的应用程序.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 小时

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

这里仍然没有奇迹

我已经能够发现这个问题在 GCP 中是已知的,团队目前正在研究它。

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

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

"${SHORT_SHA}xyz"

用于浮点数的正则表达式可以在这里找到。

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

最新更新