Bla*_*ack 4 google-cloud-platform
我们制定了一项政策,将资源限制在欧盟地区。
\n\n当我尝试执行云构建时,gcloud 希望创建一个存储桶 (gs://[PROJECT_ID]_cloudbuild) 来存储暂存源。此步骤失败,因为使用了默认存储桶位置 (\'us\'):
\n\n"code": 412,\n"message": "\'us\' violates constraint \xe2\x80\x98constraints/gcp.resourceLocations\xe2\x80\x99"\nRun Code Online (Sandbox Code Playgroud)\n\n作为解决方法,我尝试传递位于有效区域中的现有存储桶(使用 --gcs-source-staging-dir),但出现了相同的错误。
\n\n如何解决这个问题?
\n\n这里是 HTTP 日志:
\n\n$ gcloud --log-http builds submit --gcs-source-staging-dir gs://my-custom-bucket/staging \\\n--tag gcr.io/xxxxxxxxxx/quickstart-image .\n=======================\n==== request start ====\nuri: https://www.googleapis.com/storage/v1/b?project=xxxxxxxxxx&alt=json\nmethod: POST\n== headers start ==\naccept: application/json\ncontent-type: application/json\n== headers end ==\n== body start ==\n{"name": "my-custom-bucket"}\n== body end ==\n==== request end ====\n---- response start ----\n-- headers start --\nserver: UploadServer\nstatus: 412\n-- headers end --\n-- body start --\n{\n "error": {\n "errors": [\n {\n "domain": "global",\n "reason": "conditionNotMet",\n "message": "\'us\' violates constraint \xe2\x80\x98constraints/gcp.resourceLocations\xe2\x80\x99",\n "locationType": "header",\n "location": "If-Match"\n }\n ],\n "code": 412,\n "message": "\'us\' violates constraint \xe2\x80\x98constraints/gcp.resourceLocations\xe2\x80\x99"\n }\n}\n\n-- body end --\n---- response end ----\n----------------------\nERROR: (gcloud.builds.submit) HTTPError 412: \'us\' violates constraint \xe2\x80\x98constraints/gcp.resourceLocations\xe2\x80\x99\nRun Code Online (Sandbox Code Playgroud)\n
Neb*_*tic 19
我找到了这个问题的解决方案。[PROJECT_ID]_cloudbuild创建项目(启用资源位置限制)后,您应该使用首选位置中的名称创建一个新存储桶。
如果您不这样做,云构建提交将自动在美国创建一个存储桶,这是不可配置的。由于资源限制,cloud build 无法在美国创建此存储桶,并且失败并出现以下错误:
ERROR: (gcloud.builds.submit) HTTPError 412: 'us' violates constraint 'constraints/gcp.resourceLocations'
Run Code Online (Sandbox Code Playgroud)
当您(手动)创建同名的存储桶时,cloudbuild 会将该存储桶作为默认存储桶。该解决方案并不是立即可见,因为对于应用资源限制时已经有 cloudbuild 存储桶的项目,问题不会出现。
| 归档时间: |
|
| 查看次数: |
15369 次 |
| 最近记录: |