从Cloud Build部署到AppEngine(Flex)的问题

时间:2019-11-27 08:39:06

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

我面临着有关通过Cloud Build部署到AppEngine Flex环境的问题。它曾经可以正常工作,但今天却不能。这是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 Support中打开案例

这里仍然没有奇迹

1 个答案:

答案 0 :(得分:0)

我已经发现该问题已在GCP中发现,并且该小组目前正在研究该问题。

该错误是由于您正在使用的SHORT_SHA与内部Deployment Manager YAML解析器使用的正则表达式之一匹配而导致的。目前,此已知问题是由传递SHA字符串引起的,该字符串由Deployment Manager YAML解析器将评估为浮点而不是字符串,将时间戳记作为值传递还会导致解析器将字符串错误地评估为时间戳记。 / p>

然后在SHORT_SHA的末尾添加随机字符串将强制其为字符串,因此可以避免出现该问题:

"${SHORT_SHA}xyz"

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

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