排查 App Engine 柔性环境部署问题

本文档介绍如何排查 App Engine 柔性环境中的 Cloud Endpoints 部署问题。如果向 API 发送请求后收到错误响应,请参阅排查响应错误问题,了解如何排查此类错误问题。

部署错误

本部分介绍如何排查 gcloud app deploy 错误。

错误消息 问题排查
Your deployment has failed to become healthy in the allotted time and therefore was rolled back. If you believe this was an error, try adjusting the app_start_timeout_sec setting in the readiness_check section.

检查您的 app.yaml 文件是否有 readiness_check 部分且其中包含 app_start_timeout_sec 的值。如果此部分不存在,请予以添加并将 app_start_timeout_sec 的值设置为高于默认值 300 秒。如需了解详情,请参阅就绪性检查

确保在项目中启用了 Endpoints 和 ESP 所需的所有 Google Cloud 服务。如需了解详细,请参阅检查所需服务

有关 rollout_strategy 的错误消息

如您在部署之前配置了 app.yaml,则必须向其添加 endpoints_api_service 部分。可扩展服务代理 (ESP) 需要通过这部分中指定的设置为您的服务获取配置。您必须执行以下操作之一:在 config_id 字段中指定配置 ID,或者包括 rollout_strategy: managed 选项。该选项将 ESP 配置为使用最新部署的服务配置。指定此选项后,在部署新的服务配置后,ESP 最多会在 5 分钟内检测到更改并自动开始使用该服务配置。建议您指定此选项,而不是指定特定配置 ID 供 ESP 使用。例如:

endpoints_api_service:
  name: example-project-12345.appspot.com
  rollout_strategy: managed

如果 endpoints_api_service 部分不包含 ESP 获取服务配置所需的信息,则会显示以下消息之一:

错误消息 问题排查
rollout_strategy 设置为 "managed" 时,禁止使用 config_id 您不能同时指定配置 ID 和 rollout_strategy: managed。除非您有明确的理由需要使用特定配置 ID,否则我们建议您从 app.yaml 文件中移除 config_id: [YOUR_CONFIG_ID] 并重新运行 gcloud app deploy
如果 rollout_strategy 未指定或设置为 "fixed",则必须指定 config_id app.yaml 文件不包含 rollout_strategy: managed,或者 rollout_strategy 设置为 fixed 而您没有指定配置 ID 时,就会出现此错误。除非您有明确的理由使用特定配置 ID,否则我们建议您将 rollout_strategy: managed 添加到 app.yaml 文件的 endpoints_api_service 部分,并重新运行 gcloud app deploy 命令。

查看实例日志

App Engine 崩溃和系统日志提供信息来说明应用为何无法按预期启动或执行。您可以在 Endpoints 日志中找到更多调试信息。

  1. 在 Google Cloud 控制台中,通过 SSH 连接到您的虚拟机。如需了解详情,请参阅连接到实例

  2. 使用文本查看器,例如 tail

     tail -f /var/log/nginx/error.log
    

后续步骤