我在使用终端的gcloud命令触发云功能时收到错误:
gcloud functions call function_name
在云功能日志页面上,没有显示任何错误,任务也顺利完成,但是,任务完成后,终端上会显示此错误。
gcloud crashed (ReadTimeout): HTTPSConnectionPool(host='cloudfunctions.googleapis.com', port=443): Read timed out. (read timeout=300)
注意:我的功能超时设置为540秒,完成任务大约需要320秒
我认为问题是gcloud functions call
在300秒后超时,并且无法配置更长的超时时间来匹配云功能。
我创建了一个简单的Golang Cloud函数:
func HelloFreddie(w http.ResponseWriter, r *http.Request) {
log.Println("Sleeping")
time.Sleep(400*time.Second)
log.Println("Resuming")
fmt.Fprint(w, "Hello Freddie")
}
并部署了它:
gcloud functions deploy ${NAME}
--region=${REGION}
--allow-unauthenticated
--entry-point="HelloFreddie"
--runtime=go113
--source=${PWD}
--timeout=520
--max-instances=1
--trigger-http
--project=${PROJECT}
然后我用gcloud functions call ${NAME} ...
time
time
gcloud functions call ${NAME}
--region=${REGION}
--project=${PROJECT}
这个超时了:
ERROR: gcloud crashed (ReadTimeout): HTTPSConnectionPool(host='cloudfunctions.googleapis.com', port=443): Read timed out. (read timeout=300)
real 5m1.079s
user 0m0.589s
sys 0m0.107s
注意
5m1s
~==300s
但是,使用curl
:
time
curl
--request GET
--header "Authorization: Bearer $(gcloud auth print-access-token)"
$(
gcloud functions describe ${NAME}
--region=${REGION}
--project=${PROJECT}
--format="value(httpsTrigger.url)")
收益率:
Hello Freddie
real 6m43.048s
user 0m1.210s
sys 0m0.167s
注意
6m43s
~==400s
因此,gcloud functions call
在300秒后超时,这是不可配置的。
向Google的issue Tracker提交了一期。