我正在尝试创建我的第一个云函数,指向我的Github repo上镜像在谷歌云存储库上的一个分支。然而,该功能无法部署,并产生以下错误:
部署失败:
Build failed: {"cacheStats": [{"status": "MISS", "hash": "c6a7ea692f4ddc9f7088c33d4c6e337420dcdc1452daa09efb5054117e10be57", "type": "docker_layer_cache", "level": "global"}, {"status": "MISS", "hash": "c6a7ea692f4ddc9f7088c33d4c6e337420dcdc1452daa09efb5054117e10be57", "type": "docker_layer_cache", "level": "project"}]}
以下是来自错误日志的更多信息:
protoPayload: {
@type: "type.googleapis.com/google.cloud.audit.AuditLog"
authenticationInfo: {
principalEmail: "paul.devito@output.com"
}
methodName: "google.cloud.functions.v1.CloudFunctionsService.CreateFunction"
resourceName: "projects/second-casing-278016/locations/us-west2/functions/RetentionPredictionFunction-TESTBRANCH"
serviceName: "cloudfunctions.googleapis.com"
status: {
code: 3
message: "Build failed: {"cacheStats": [{"status": "MISS", "hash": "c6a7ea692f4ddc9f7088c33d4c6e337420dcdc1452daa09efb5054117e10be57", "type": "docker_layer_cache", "level": "global"}, {"status": "MISS", "hash": "c6a7ea692f4ddc9f7088c33d4c6e337420dcdc1452daa09efb5054117e10be57", "type": "docker_layer_cache", "level": "project"}]}"
}
}
receiveTimestamp: "2020-07-28T20:37:01.643381187Z"
从创建功能请求日志:
{
insertId: "fjgtmse38h4w"
logName:
operation: {
first: true
id: "operations/c2Vjb25kLWNhc2luZy0yNzgwMTYvdXMtd2VzdDIvUmV0ZW50aW9uUHJlZGljdGlvbkZ1bmN0aW9uLVRFU1RCUkFOQ0gvX3ZfNWZtU2RITHM"
producer: "cloudfunctions.googleapis.com"
}
protoPayload: {
@type: "type.googleapis.com/google.cloud.audit.AuditLog"
authenticationInfo: {…}
authorizationInfo: [1]
methodName: "google.cloud.functions.v1.CloudFunctionsService.CreateFunction"
request: {
@type: "type.googleapis.com/google.cloud.functions.v1.CreateFunctionRequest"
function: {
availableMemoryMb: 1024
entryPoint: "daily_retention_prediction_procedure"
eventTrigger: {…}
ingressSettings: "ALLOW_ALL"
labels: {
deployment-tool: "console-cloud"
}
maxInstances: 1
name:
runtime: "python37"
serviceAccountEmail:
sourceRepository: {
url:
timeout: "540s"
}
location:
}
requestMetadata: {…}
resourceLocation: {…}
resourceName:
serviceName: "cloudfunctions.googleapis.com"
}
receiveTimestamp: "2020-07-28T20:34:08.301085522Z"
resource: {
labels: {…}
type: "cloud_function"
}
severity: "NOTICE"
timestamp: "2020-07-28T20:34:07.489Z"
}
我在网上能找到的唯一一个错误是谷歌宕机,但网站显示所有系统都在运行。我能做些什么来调试它?
已解决!
在检查了Pub/Sub触发器的python代码示例后,我意识到我缺少了entry函数的默认参数:
def hello_pubsub(event, context):
...
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/functions/helloworld/main.py