![无法使用云函数构建任何函数](https://linux22.com/image/771719/%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%E4%BA%91%E5%87%BD%E6%95%B0%E6%9E%84%E5%BB%BA%E4%BB%BB%E4%BD%95%E5%87%BD%E6%95%B0.png)
不知何故,我在我们的新云环境中不断遇到构建失败。我尝试使用 nodejs 和 python 默认 HelloWorld 云函数,均失败且没有特定的错误消息。以下是其中一个错误:
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: {"error":{"buildpackId":"","buildpackVersion":"","errorType":"OK","canonicalCode":"OK","errorId":"","errorMessage":""},"stats":[{"buildpackId":"google.utils.archive-source","buildpackVersion":"0.0.1","totalDurationMs":45,"userDurationMs":41},{"buildpackId":"google.python.functions-framework","buildpackVersion":"0.9.5","totalDurationMs":78,"userDurationMs":78},{"buildpackId":"google.python.pip","buildpackVersion":"0.9.2","totalDurationMs":5190,"userDurationMs":5186},{"buildpackId":"google.utils.label","buildpackVersion":"0.0.1","totalDurationMs":0,"userDurationMs":0}],"warnings":null}
答案1
我确实遇到了同样的问题。甚至示例都不起作用(尝试了 python 和 nodejs,以及 Terraform 模块示例)。
深入研究后,我在 Cloud Build History 中发现了一些构建日志:
"build": eu.gcr.io/<project-id>/gcf/<region>/<some-uuid>:hello_gcs_version-2 - GET https://eu.gcr.io/v2/token?scope=repository%3A<project-id>%2Fgcf%2F<region>%2F<same-uuid>%3Apush%2Cpull&scope=repository%3Afn-img%2Fbuildpacks%2Fpython39%2Frun%3Apull&service=eu.gcr.io: DENIED: Token exchange failed for project '<project-id>'. Org Policy Violated: 'eu' violates constraint 'constraints/gcp.resourceLocations'
对我来说,需要做的是覆盖组织政策(https://console.cloud.google.com/iam-admin/orgpolicies/gcp-resourceLocations/edit-v2)并使其“Google 管理”