无法在云运行中创建新的GCP端点

问题描述 投票:0回答:1

我正在使用Cloud Run,端点和Cloud Functions构建API服务。有多个端点运行得很好,但是我不再能够部署任何新的端点。

Cloud Run环境有一个错误,导致它无法调用相应的Cloud Function。奇怪的是,所有其他端点都可以正常工作,但是我无法创建新端点。

我发现了这篇文章:https://cloud.google.com/endpoints/docs/openapi/troubleshoot-response-errors,但这仅用于BAD_GATEWAY错误代码。所有代码都已完全部署好。部署Cloud Function,Cloud Run或Open API yaml文件时没有错误。

响应错误:

{
 "code": 13,
 "message": "INTERNAL_SERVER_ERROR",
 "details": [
  {
   "@type": "type.googleapis.com/google.rpc.DebugInfo",
   "stackEntries": [],
   "detail": "application"
  }
 ]
}

Cloud Run中的错误:

5#5: *33 invalid URL prefix in "", client: xxxxx, server: , request: "GET /user HTTP/1.1", host: "[my cloud run host]" 
GET 500 404 B4 ms python-requests/2.22.0 [cloud run host]/user

main.py文件:

def user(request):

    return "Ok"

yaml文件:

/user:
 x-google-backend:
    address: https://[cloud functions host]/user
 get:
  summary: Retrieves a user.
  operationId: getUser
  responses:
    '200':
      description: A successful response
    '400':
      description: BAD_REQUEST
google-cloud-platform google-cloud-functions google-cloud-endpoints google-cloud-run
1个回答
0
投票

如果我们查看您的YAML:

/user:
 x-google-backend:
    address: https://[cloud functions host]/user
 get:
  summary: Retrieves a user.
  operationId: getUser
  responses:
    '200':
      description: A successful response
    '400':
      description: BAD_REQUEST

...特别注意x-google-backend部分。请注意,这在/user路径部分内部存在。现在请注意,该地址是URL 带有路径。您不需要URL中的路径部分,而只需要主机的地址(和可选端口)。将您的YAML开头更改为:

/user:
 x-google-backend:
    address: https://[cloud functions host]

/user部分已从address行中删除]

© www.soinside.com 2019 - 2024. All rights reserved.