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

big*_*big 1 google-app-engine google-cloud-platform google-cloud-build

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

\n\n
... (skipped composer\'s things) ...\nStep #1 Updating service [legacy-api] (this may take several minutes)...\nStep #1: ..............................................................................................................................................................................................................................................................................................failed.\nStep #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 \xe2\x80\xa6/operation-\xe2\x80\xa6 errors: [code: "RESOURCE_ERROR"\nStep #1: location: "/deployments/\xe2\x80\xa6/resources/\xe2\x80\xa6-00it"\nStep #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\\"}}"\nStep #1: ] \n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的 cloudbuild.yaml

\n\n
steps:\n  - name: \'gcr.io/$PROJECT_ID/secrets:latest\'\n    entrypoint: sh\n    args: \n      - "-c"\n      - |\n        cat /secrets/$_ENV/environments/${_SERVICE_NAME}.env > .env\n  - name: \'gcr.io/cloud-builders/gcloud\'\n    args: ["app", "deploy", "--version=$SHORT_SHA", "--promote", "--stop-previous-version", "./app.yaml"]\ntimeout: 1200s\n\nsubstitutions:\n  _ENV: staging\n  _SERVICE_NAME: legacy-api\n\n
Run Code Online (Sandbox Code Playgroud)\n\n

这是我的 app.yaml

\n\n
service: legacy-api\nruntime: php\nenv: flex\n\nruntime_config:\n  document_root: public\n  enable_stackdriver_integration: true\n\nresources:\n  cpu: 4\n  memory_gb: 8\n\nbeta_settings:\n    cloud_sql_instances: ${CLOUD_SQL_INSTANCE}\n\nnetwork:\n  name: default\n
Run Code Online (Sandbox Code Playgroud)\n\n

现在,这阻碍了我的开发进程。请帮忙。

\n\n

提前致谢!

\n\n

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

\n\n

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

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

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

\n\n

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

\n\n

这里仍然没有奇迹

\n

bhi*_*ito 6

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

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

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

"${SHORT_SHA}xyz"

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

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