进行一些调整(相当大的PR)后,基本上将Google Cloud Storage连接添加到此功能,部署开始失败。不幸的是,错误消息还不清楚,因此并没有给我太多提示。在本地和测试中一切正常,所以我现在迷失了要搜索哪个方向。日志也不提供任何见解。
不幸的是,无法真正轻松地共享PR中的更改。最坏的情况是我会还原并从那里一步一步来,但这是一个乏味的过程。
在部署中使用的服务帐户可以访问使用过的存储桶(具有写入功能),但是我也不认为此错误提示了权限,否则我希望错误消息会更深入。
使用的命令:
gcloud beta functions deploy eventStreamPostEvent --runtime nodejs10 --memory 128MB --trigger-http --source ./dist --service-account $DEPLOY_SERVICE_ACCOUNT --verbosity debug
Deploying function (may take a while - up to 2 minutes)...
..............................failed.
DEBUG: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Provided code is not a loadable module.
Could not load the function, shutting down.
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 985, in Execute
resources = calliope_command.Run(cli=self, args=args)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 795, in Run
resources = command_instance.Run(args)
File "/usr/lib/google-cloud-sdk/lib/surface/functions/deploy.py", line 231, in Run
enable_vpc_connector=True)
File "/usr/lib/google-cloud-sdk/lib/surface/functions/deploy.py", line 175, in _Run
return api_util.PatchFunction(function, updated_fields)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 300, in CatchHTTPErrorRaiseHTTPExceptionFn
return func(*args, **kwargs)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/util.py", line 356, in PatchFunction
operations.Wait(op, messages, client, _DEPLOY_WAIT_NOTICE)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 126, in Wait
_WaitForOperation(client, request, notice)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 101, in _WaitForOperation
sleep_ms=SLEEP_MS)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 219, in RetryOnResult
result = func(*args, **kwargs)
File "/usr/lib/google-cloud-sdk/lib/googlecloudsdk/api_lib/functions/operations.py", line 65, in _GetOperationStatus
raise exceptions.FunctionsError(OperationErrorToString(op.error))
FunctionsError: OperationError: code=3, message=Function failed on loading user code. Error message: Provided code is not a loadable module.
Could not load the function, shutting down.
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Provided code is not a loadable module.
Could not load the function, shutting down.
我希望任何人都知道导致此错误的原因。
Stackdriver日志仅显示以下内容:
protoPayload: {
@type: "type.googleapis.com/google.cloud.audit.AuditLog"
authenticationInfo: {…}
methodName: "google.cloud.functions.v1.CloudFunctionsService.UpdateFunction"
requestMetadata: {
destinationAttributes: {…}
requestAttributes: {…}
}
resourceName: "projects/<projectName>/locations/europe-west1/functions/eventStreamPostEvent"
serviceName: "cloudfunctions.googleapis.com"
status: {
code: 3
message: "INVALID_ARGUMENT"
}
}
答案 0 :(得分:0)
我遇到了同样的问题,似乎该消息来自here。
当函数的根文件夹中有多个带有某些子文件夹的.js文件时,默认情况下,没有任何规范,您需要将输入模块命名为index.js或function.js。
我发现通过使用node8部署功能。错误消息应该更清晰...
答案 1 :(得分:0)
通常(或对我而言)是OperationError的原因:code = 3是导入定义的模块时出错。
通过以下方式解决此问题:
删除节点模块
rm -r .\node_modules\
可选::您可以在删除node_modules之后执行npm i
并在部署之前在本地测试功能。
然后删除.gcloudignore
并照常部署。