Brian Burton
Brian Burton

Reputation: 3842

Standard App Engine project wrongly deployed as flexible

I have had a few python apps running on App Engine standard environment for a few years, the last successful deployment being April 7, 2017. Today when trying to deploy an update using this command:

    gcloud.cmd app deploy --project <redacted-project-id> -v 5 --promote --quiet

I'm receiving the following error:

    Updated property [core/project].
    Services to deploy:

    descriptor:      [D:\Projects\appengine\app.yaml]
    source:          [D:\Projects\appengine]
    target project:  [<redacted-project-id>]
    target service:  [default]
    target version:  [5]
    target url:      [https://<redacted-project-id>.appspot.com]


    If this is your first deployment, this may take a while...failed.
    WARNING: We couldn't validate that your project is ready to deploy to App Engine Flexible Environment. If deployment fails, please check the following message and try again:
    Server responded with code [400]:
      Bad Request Unexpected HTTP status 400.
      Failed Project Preparation (app_id='s~<redacted-project-id>'). Out of retries.  Last error: Temporary error occurred while verifying project: TEMPORARY_ERROR: Operation does not satisfy the following requirements: billing-enabled {Billing must be enabled for activation of service '' in project '<redacted-project-id>' to proceed., https://console.developers.google.com/project/<redacted-project-id>/settings}
    com.google.api.management.server.common.exceptions.ServiceManagementNonRetriableStorageException: Operation does not satisfy the following requirements: billing-enabled {Billing must be enabled for activation of service '' in project '<redacted-project-id>' to proceed., https://console.developers.google.com/project/<redacted-project-id>/settings}
    Beginning deployment of service [default]...
    Building and pushing image for service [default]
    Some files were skipped. Pass `--verbosity=info` to see which ones.
    You may also view the gcloud log file, found at
    [C:\Users\Brian\AppData\Roaming\gcloud\logs\2017.07.04\22.44.12.404000.log].
    ERROR: (gcloud.app.deploy) You do not have permission to access project [<redacted-project-id>] (or it may not exist): The caller does not have permission

I enabled billing for this project and it attempted to create a docker as if I wanted to use the flexible environment.

    Updated property [core/project].
    Services to deploy:

    descriptor:      [D:\Projects\appengine\app.yaml]
    source:          [D:\Projects\appengine]
    target project:  [<redacted-project-id>]
    target service:  [default]
    target version:  [5]
    target url:      [https://<redacted-project-id>.appspot.com]


    If this is your first deployment, this may take a while...done.

    Beginning deployment of service [default]...
    Building and pushing image for service [default]
    Some files were skipped. Pass `--verbosity=info` to see which ones.
    You may also view the gcloud log file, found at
    [C:\Users\Brian\AppData\Roaming\gcloud\logs\2017.07.04\22.56.43.574000.log].
    Started cloud build [818a94e7-584a-46a2-be15-bdb304b38fd3].
    To see logs in the Cloud Console: https://console.cloud.google.com/gcr/builds/818a94e7-584a-46a2-be15-bdb304b38fd3?project=<redacted-project-id>
    ----------------------------- REMOTE BUILD OUTPUT ------------------------------
    starting build "818a94e7-584a-46a2-be15-bdb304b38fd3"

    FETCHSOURCE
    Fetching storage object: gs://staging.<redacted-project-id>.appspot.com/us.gcr.io/<redacted-project-id>/appengine/default.5:latest#1499201946081566
    Copying gs://staging.<redacted-project-id>.appspot.com/us.gcr.io/<redacted-project-id>/appengine/default.5:latest#1499201946081566...
    | [1 files][ 79.1 MiB/ 79.1 MiB]
    Operation completed over 1 objects/79.1 MiB.                                    
    BUILD
    Already have image (with digest): gcr.io/cloud-builders/docker
    Sending build context to Docker daemon  184.6MB
    Step 1/2 : FROM gcr.io/google-appengine/php:latest
    latest: Pulling from google-appengine/php
    Digest: sha256:eeafc3e85abe6fb29b39fd87c73342527e2fdefc6ec173d55c60378e36b51fab
    Status: Downloaded newer image for gcr.io/google-appengine/php:latest
    # Executing 3 build triggers...
    Step 1/1 : COPY . $APP_DIR
    Step 1/1 : RUN chown -R www-data.www-data $APP_DIR


    Command killed by keyboard interrupt

Why it was creating a PHP docker for a Python project is a mystery. Is this a bug or is it a misconfiguration on my end due to recent gcloud component updates?


My app.yaml file as requested:

    runtime: python27
    api_version: 1
    threadsafe: yes

    default_expiration: "7d 0h"

    handlers: 
    - url: /robots.txt
      static_files: static/robots.txt
      upload: static/robots.txt

    - url: /fonts/(.*\.otf)
      static_files: static/fonts/\1
      upload: static/fonts/(.*\.otf)
      mime_type: application/x-font-otf

    - url: /fonts/(.*\.ttf)
      static_files: static/fonts/\1
      upload: static/fonts/(.*\.ttf)
      mime_type: application/x-font-ttf

    - url: /fonts/(.*\.eot)
      static_files: static/fonts/\1
      upload: static/fonts/(.*\.eot)
      mime_type: application/vnd.ms-fontobject

    - url: /fonts/(.*\.svg)
      static_files: static/fonts/\1
      upload: static/fonts/(.*\.svg)
      mime_type: image/svg+xml

    - url: /fonts/(.*\.woff)
      static_files: static/fonts/\1
      upload: static/fonts/(.*\.woff)
      mime_type: application/font-woff

    - url: /fonts/(.*\.woff2)
      static_files: static/fonts/\1
      upload: static/fonts/(.*\.woff2)
      mime_type: application/font-woff2

    - url: /BingSiteAuth.xml
      static_files: static/BingSiteAuth.xml
      upload: static/BingSiteAuth.xml

    - url: /favicon.ico
      static_files: static/img/favicon.ico
      upload: static/img/favicon.ico

    - url: /(.*\.txt)
      static_files: static/verification/\1
      upload: static/verification/(.*\.txt)

    - url: /static
      static_dir: static

    - url: /tasks/.*
      script: main.app
      login: admin

    - url: /cron/.*
      script: main.app
      login: admin

    - url: /.*
      script: main.app

    error_handlers:
    - error_code: over_quota
      file: static/over_quota.html


    libraries:
    - name: webapp2
      version: latest
    - name: jinja2
      version: latest
    - name: lxml
      version: latest
    - name: numpy
      version: "1.6.1"
    - name: pycrypto
      version: latest

Possible solution: This appears to be a bug caused by deploying with gcloud.cmd. I am able to deploy one app using appcfg.py like this:

    python.exe -u "C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\appcfg.py" --oauth2_credential_file=C:\Users\Brian\.appcfg_oauth2 --application=<redacted-project-id> --version=5 update appengine

It worked on one app, the other app is failing with a similar error as above, "Bad Request Unexpected HTTP status 400".

Upvotes: 1

Views: 423

Answers (1)

Brian Burton
Brian Burton

Reputation: 3842

I discovered the solution, it was on my end. The above errors are caused because my deploy script was providing the wrong path to my codebase when calling gcloud app deploy. It was executing one directory above the codebase, which results in the above errors. Hope that helps someone else.

Upvotes: 1

Related Questions