[13] An internal error occurred.

Google Cloud App Engine 部署問題摘要

專案 ID: meeting2496
目標服務: Google App Engine 標準環境 (Standard Environment)
執行環境 (Runtime): python311
遇到的問題: 在多次嘗試部署 Flask 應用程式到 Google App Engine 標準環境時,持續遇到 ERROR: (gcloud.app.deploy) Error Response: [13] An internal error occurred. 錯誤。此錯誤在執行 gcloud app deploy 指令的最後階段出現。
已嘗試的解決方案與排查步驟:

  1. 多次部署嘗試: 在過去的幾個小時內進行了多次部署嘗試,均以相同的內部錯誤告終。

  2. 服務帳戶權限驗證與設定:

    • 部署服務帳戶: meeting-app-deployer@meeting2496.iam.gserviceaccount.com
    • 已為此服務帳戶確認並重複授予以下 IAM 角色:
      • App Engine Admin (roles/appengine.admin)
      • Service Account User (roles/iam.serviceAccountUser) - 同時也確保此帳戶有權限在 App Engine 預設服務帳戶 (meeting2496@appspot.gserviceaccount.com) 上作為使用者。
      • Storage Object Creator (roles/storage.objectCreator)
      • Storage Object Viewer (roles/storage.objectViewer)
      • Service Usage Admin (roles/serviceusage.serviceUsageAdmin) - 以確保 appengine.googleapis.com API 能夠被啟用。日誌曾一度顯示此權限 granted: false,但後續已多次確認並重新授予此角色。
  3. app.yaml 設定檢查:

    • 確認 runtime: python311 設定正確。

    • 確認 entrypoint: gunicorn -b :$PORT src.main:app 為標準啟動指令。

    • 檔案內容如下:

      yaml

      runtime: python311
      entrypoint: gunicorn -b :$PORT src.main:app
      instance_class: F1
      automatic_scaling:
        min_instances: 0
        max_instances: 1
      handlers:
      - url: /static
        static_dir: src/static
      - url: /.*
        script: auto
      
      
  4. requirements.txt 相容性檢查與修改:

    • 檢查了所有套件與 Python 3.11 的相容性。

    • 根據 GCP Support 先前的建議,移除了 requirements.txt 中所有套件的版本號,以允許 App Engine 建置過程自行選擇最相容的版本。修改後的 requirements.txt 內容如下:

      txt

      Flask
      Flask-SQLAlchemy
      PyMySQL
      SQLAlchemy
      cryptography
      pandas
      spacy
      openpyxl
      gunicorn
      
      
    • 即使在移除版本號後重新部署,依然遇到相同的內部錯誤 [13]。

  5. Shared VPC 確認:

    • 根據 GCP Support 先前回覆中關於 Shared VPC 的提示,我們確認部署目標是 App Engine 標準環境,而非彈性環境。需要向 GCP Support 確認專案 meeting2496 是否有啟用 Shared VPC 設定,若無,則 Shared VPC 相關的排查方向可能不適用。
  6. 使用 --verbosity=debug 重新部署:

    • 最近一次部署嘗試(ID: gcp_deploy_attempt_debug)使用了 gcloud app deploy … --verbosity=debug 標誌。

    • 偵錯日誌的關鍵部分顯示操作完成,但帶有錯誤:

      json

      {
          "done": true,
          "error": {
              "code": 13,
              "message": "An internal error occurred."
          },
          "metadata": {
              "@type": "type.googleapis.com/google.appengine.v1.OperationMetadataV1",
              "endTime": "2025-05-14T01:18:43.079Z",
              "insertTime": "2025-05-14T01:18:40.920Z",
              "method": "google.appengine.v1.Versions.CreateVersion",
              "target": "apps/meeting2496/services/default/versions/prod-debug-20250513-211838",
              "user": "meeting-app-deployer@meeting2496.iam.gserviceaccount.com"
          },
          "name": "apps/meeting2496/operations/5351cd5f-c8b3-4819-adc0-334675cb3758"
      }
      
      
    • 最終錯誤訊息依然是:ERROR: (gcloud.app.deploy) Error Response: [13] An internal error occurred.
      結論: 經過多方面的排查與嘗試,包括權限設定、應用程式組態檔修改以及遵循 GCP Support 的初步建議,部署失敗的問題(錯誤代碼 13)依然存在。這強烈暗示問題可能源於 Google Cloud Platform 後端服務的內部狀況。
      建議 GCP Support 團隊從後端服務日誌或內部監控系統深入調查此 Error Response: [13],特別是針對專案 meeting2496 在上述時間點的部署操作。

Hello,

The information in the post looks like copy-n-paste from a feedback report. We do not have sufficient capabilities to help troubleshooting problems and, frankly, this is outside of the scope of this forum.

Having said that, if you are able to share a minimized version of the application that generates this output when deployed, we can try to reproduce it and see if we can find any reasons for this behavior.

The “internal error” does not necessary point to a problem with Google Cloud Platform. It can be a problem with gcloud CLI tool or some other problem that cannot be clearly described. If you are able to minimize the application so you can share it with us, we can try to help you. Otherwise, you can try to simplify your application to see if, at any step, you are able to deploy it.

Please mind that if it is an attempt to deploy over existing instance and this instance is Gen1, this generation is no longer supported.