google-github-actions / deploy-appengine

A GitHub Action that deploys source code to Google App Engine.
https://cloud.google.com/appengine
254 stars 72 forks source link

Better logging of failures #347

Closed Molkree closed 10 months ago

Molkree commented 10 months ago

TL;DR

When deployment fails after the build stage we don't get enough info to triage compared to local deployment.

Expected behavior

Output of GitHub Action matching local error reporting.

Observed behavior

Build output cuts off in the middle and no error afterwards is preserved for output. From the log, it's not even clear if the build was successful (it was in our case) but most importantly, the output simply states

failed to execute gcloud command `gcloud app deploy --quiet --format json app.yaml --promote`

without actual underlying error. Same in debug run. When running locally the actual error for us was:

ERROR: (gcloud.app.deploy) Error Response: [9] An internal error occurred while processing task /app-engine-flex/flex_await_healthy/flex_await_healthy>2024-01-16T07:41:22.689Z82939.in.1: Your deployment has exceeded quota in your project. Please increase quotas and try again. For more information, see https://cloud.google.com/appengine/quotas#flex.

Action YAML

name: Deploy
on:
  push:
    branches: [master]
  workflow_dispatch:
  release:
    types: [published]
jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
        contents: read
        id-token: write
    environment: ${{ github.event_name == 'push' && 'development' || 'production' }}
    steps:
        - uses: actions/checkout@v4
        - name: Authenticate to Google Cloud
          uses: google-github-actions/auth@v2
          with:
            workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
            service_account: ${{ secrets.SERVICE_ACCOUNT }}
        - name: Switch to production deployment
          if: ${{ github.event_name != 'push' }}
          run: |
            sed -i 's/development/production/g' app.yaml
        - name: Deploy to App Engine
          uses: google-github-actions/deploy-appengine@v2
          with:
            env_vars: |-
                MAINDB_PG_CONNECTION_STRING=${{ secrets.MAINDB_PG_CONNECTION_STRING }}
                MAINDB_V2_PG_CONNECTION_STRING=${{ secrets.MAINDB_V2_PG_CONNECTION_STRING }}
                SENTRY_DSN=${{ secrets.SENTRY_DSN }}
                AIRFLOW_API_GCP_CREDENTIALS_BASE64=${{ secrets.AIRFLOW_API_GCP_CREDENTIALS_BASE64 }}
                ENVIRONMENT=${{ vars.ENVIRONMENT }}
                AUTH_ACCESS_TOKEN_KEY=${{ secrets.AUTH_ACCESS_TOKEN_KEY }}

Log output

2024-01-16T08:02:30.1626331Z ##[debug]Caching tool gcloud 459.0.0 x64
2024-01-16T08:02:30.1627518Z ##[debug]source dir: /home/runner/work/_temp/7612c66b-b7a8-4474-8dbb-d3551f2bc9e8/google-cloud-sdk
2024-01-16T08:02:30.1628761Z ##[debug]destination /opt/hostedtoolcache/gcloud/459.0.0/x64
2024-01-16T08:02:37.0639786Z ##[debug]finished caching tool
2024-01-16T08:02:37.0646702Z ##[debug]Running command: gcloud --quiet auth login --force --cred-file /home/runner/work/company-api/company-api/gha-creds-f721afbe355b358c.json
2024-01-16T08:02:40.4495557Z Successfully authenticated
2024-01-16T08:02:40.4498578Z Running: gcloud app deploy --quiet --format json app.yaml --promote
2024-01-16T08:07:41.0094895Z ##[error]google-github-actions/deploy-appengine failed with: failed to execute gcloud command `gcloud app deploy --quiet --format json app.yaml --promote`: Services to deploy:

descriptor:                  [/home/runner/work/company-api/company-api/app.yaml]
source:                      [/home/runner/work/company-api/company-api]
target project:              [starry-braid-999999]
target service:              [company-api-development]
target version:              [20240116t080242]
target url:                  [https://company-api-development-dot-starry-braid-999999.uc.r.appspot.com]
target service account:      [starry-braid-999999@appspot.gserviceaccount.com]

Beginning deployment of service [company-api-development]...
╔════════════════════════════════════════════════════════════╗
╠═ Uploading 0 files to Google Cloud Storage                ═╣
╚════════════════════════════════════════════════════════════╝
File upload done.
Updating service [company-api-development] (this may take several minutes)...
................................done.
----------------------------- REMOTE BUILD OUTPUT ------------------------------
starting build "d91f2981-7d05-46db-bcda-5a3cd31d6e67"

FETCHSOURCE
BUILD
Starting Step #0 - "fetch"
Step #0 - "fetch": Pulling image: us.gcr.io/gae-runtimes/utilities/gcs-fetcher:base_20231205_18_04_RC00
Step #0 - "fetch": base_20231205_18_04_RC00: Pulling from gae-runtimes/utilities/gcs-fetcher
Step #0 - "fetch": Digest: sha256:ef219cfc5cc375ebf6624e33cfd57eff30aad2988f2cf8f27e4e09cac32a3a6e
Step #0 - "fetch": Status: Downloaded newer image for us.gcr.io/gae-runtimes/utilities/gcs-fetcher:base_20231205_18_04_RC00
Step #0 - "fetch": us.gcr.io/gae-runtimes/utilities/gcs-fetcher:base_20231205_18_04_RC00
Step #0 - "fetch": Fetching manifest gs://staging.starry-braid-999999.appspot.com/ae/00800483-1228-4188-aac7-87464a7eae1d/manifest.json.
Step #0 - "fetch": Processing 56 files.
Step #0 - "fetch": ******************************************************
Step #0 - "fetch": Status:                      SUCCESS
Step #0 - "fetch": Started:                     2024-01-16T08:02:51Z
Step #0 - "fetch": Completed:                   2024-01-16T08:02:51Z
Step #0 - "fetch": Requested workers:    200
Step #0 - "fetch": Actual workers:        56
Step #0 - "fetch": Total files:           56
Step #0 - "fetch": Total retries:          0
Step #0 - "fetch": GCS timeouts:           0
Step #0 - "fetch": MiB downloaded:         0.15 MiB
Step #0 - "fetch": MiB/s throughput:       0.86 MiB/s
Step #0 - "fetch": Time for manifest:    112.91 ms
Step #0 - "fetch": Total time:             0.29 s
Step #0 - "fetch": ******************************************************
Finished Step #0 - "fetch"
Starting Step #1 - "pre-buildpack"
Step #1 - "pre-buildpack": Pulling image: us.gcr.io/gae-runtimes/buildpacks/google-gae-22/python/builder:python_20240108_RC00
Step #1 - "pre-buildpack": python_20240108_RC00: Pulling from gae-runtimes/buildpacks/google-gae-22/python/builder
Step #1 - "pre-buildpack": 5e8117c0bd28: Already exists
Step #1 - "pre-buildpack": d9465b8a7b12: Already exists
Step #1 - "pre-buildpack": 5a0d2f7b41d3: Already exists
Step #1 - "pre-buildpack": 4fa1bc20568a: Pulling fs layer
Step #1 - "pre-buildpack": 21083009a451: Pulling fs layer
Step #1 - "pre-buildpack": 7fc2cba66626: Pulling fs layer
Step #1 - "pre-buildpack": dc1dad97263e: Pulling fs layer
Step #1 - "pre-buildpack": 116617d91f50: Pulling fs layer
Step #1 - "pre-buildpack": 3faab7bb39ed: Pulling fs layer
Step #1 - "pre-buildpack": 06f428a8446f: Pulling fs layer
Step #1 - "pre-buildpack": 811922512b57: Pulling fs layer
Step #1 - "pre-buildpack": 364092b1a7a5: Pulling fs layer
Step #1 - "pre-buildpack": 5dae4ade56f6: Pulling fs layer
Step #1 - "pre-buildpack": 2335cae80d6e: Pulling fs layer
Step #1 - "pre-buildpack": f151360c4a52: Pulling fs layer
Step #1 - "pre-buildpack": ab2fe68f3967: Pulling fs layer
Step #1 - "pre-buildpack": a425eea693d8: Pulling fs layer
Step #1 - "pre-buildpack": b280a1a8758c: Pulling fs layer
Step #1 - "pre-buildpack": efc7ae208fa9: Pulling fs layer
Step #1 - "pre-buildpack":
2024-01-16T08:07:41.0127168Z ##[debug]Restoring original app.yaml contents
2024-01-16T08:07:41.0128809Z ##[debug]Node Action run completed with exit code 1
2024-01-16T08:07:41.0135961Z ##[debug]Finishing: Deploy to App Engine

Additional information

0_deploy.txt