【问题标题】:Unable to Create New GCP Endpoints in Cloud Run无法在 Cloud Run 中创建新的 GCP 端点
【发布时间】:2020-02-28 15:29:16
【问题描述】:

我正在使用 Cloud Run、Endpoints 和 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

【问题讨论】:

  • Stackdriver Logging 中是否记录了任何错误?
  • 查看“Cloud Run 中的错误”下的错误

标签: google-cloud-platform google-cloud-functions google-cloud-endpoints google-cloud-run


【解决方案1】:

如果我们查看您的 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 行中删除)

【讨论】:

猜你喜欢
  • 2020-01-26
  • 2022-08-18
  • 2020-12-02
  • 2020-02-17
  • 1970-01-01
  • 2023-03-22
  • 2020-02-17
  • 2021-08-29
  • 2021-06-12
相关资源
最近更新 更多