标准App Engine项目错误地部署为灵活

时间:2017-07-04 21:20:38

标签: python google-app-engine

我已经在App Engine 标准环境上运行了几个python应用程序几年,最后一次成功部署是2017年4月7日。今天尝试使用此命令部署更新时:< / p>

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

我收到以下错误:

    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

我为这个项目启用了计费,它试图创建一个docker,好像我想要使用灵活的环境。

    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

为什么它为Python项目创建PHP docker是一个谜。这是一个错误还是由于最近的gcloud组件更新而导致我的错误配置?

我的app.yaml文件按要求:

    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

可能的解决方案:这似乎是因使用gcloud.cmd进行部署而导致的错误。我可以使用appcfg.py部署一个应用程序,如下所示:

    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

它在一个应用程序上工作,另一个应用程序失败,出现类似的错误,“错误请求意外的HTTP状态400”。

1 个答案:

答案 0 :(得分:1)

我发现了解决方案,它就在我的最后。导致上述错误的原因是我的部署脚本在调用gcloud app deploy时为我的代码库提供了错误的路径。它正在执行代码库上方的一个目录,从而导致上述错误。希望能帮助别人。