Search code examples
pythongoogle-app-enginegoogle-cloud-endpoints

Endpoints quickstart-app-engine for Python deploy error


I'm trying to following the step-by-step tutorial found here, but the deploy just does not work, always returning Error Response: [13] An internal error occurred.

I did not change anything in the example code itself. As I said, I just followed the linked tutorial carefully. It fails and return the error above when I try gcloud app deploy.

Using gcloud app deploy --verbosity debug it brings some stacktrace, but without any usefull meaning. I'm copying below for completeness:

Updating service [default] (this may take several minutes)...failed.
DEBUG: (gcloud.app.deploy) Error Response: [13] An internal error occurred
Traceback (most recent call last):
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 791, in Execute
    resources = calliope_command.Run(cli=self, args=args)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 756, in Run
    resources = command_instance.Run(args)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/surface/app/deploy.py", line 65, in Run
    parallel_build=False)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 587, in RunDeploy
    flex_image_build_option=flex_image_build_option)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/command_lib/app/deploy_util.py", line 395, in Deploy
    extra_config_settings)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/appengine_api_client.py", line 188, in DeployService
    message=message)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 244, in WaitForOperation
    sleep_ms=retry_interval)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 266, in WaitFor
    sleep_ms=sleep_ms)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/core/util/retry.py", line 222, in RetryOnResult
    if not should_retry(result, state):
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/util/waiter.py", line 260, in _IsNotDone
    return not poller.IsDone(operation)
  File "/Users/jamesmiranda/Documents/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/operations_util.py", line 169, in IsDone
    encoding.MessageToPyValue(operation.error)))
OperationError: Error Response: [13] An internal error occurred
ERROR: (gcloud.app.deploy) Error Response: [13] An internal error occurred

Below is the app.yaml (exactly tha same of example git, except for the APPID):

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  python_version: 3

# [START configuration]
endpoints_api_service:
  # The following values are to be replaced by information from the output of
  # 'gcloud endpoints services deploy openapi-appengine.yaml' command.
  name:  echo-api.endpoints.MYAPPID.cloud.goog
  config_id: [2018-01-09r1]
 # [END configuration]

What I tried until now:

  • Change python version to python 2 (python_version: 2);
  • Include some files to skip in the app.yaml (copied from endpoint framework in standard env tutorial);

    skip_files:

    - ^(.*/)?#.*#$

    - ^(.*/)?.*~$

    - ^(.*/)?.*\.py[co]$

    - ^(.*/)?.*/RCS/.*$

    - ^(.*/)?\..*$

    - ^(.*/)?setuptools/script \(dev\).tmpl$

  • Tried the workaround from here;

    gcloud config set app/use_deprecated_preparation True

NOthing worked. What I'm doing wrong?

Notes:

  • It works fine locally following the README info;
  • Everything works in GAE standard env folowing this another tutorial;
  • I did not found any problem in the Endpoint itself (I can see it deployed in API explorer), but the app deploy did not work in any way.

Solution

  • If the app.yaml file you are using is exactly the same as the one you copied in your question then there seems to be an error in the name and config-id you are entering. With the info provided in your question your app.yaml should look like:

    runtime: python
    env: flex
    entrypoint: gunicorn -b :$PORT main:app
    
    runtime_config:
      python_version: 3
    
    # [START configuration]
    endpoints_api_service:
      # The following values are to be replaced by information from the output of
      # 'gcloud endpoints services deploy openapi-appengine.yaml' command.
      name:  "echo-api.endpoints.MYAPPID.cloud.goog"
      config_id: "2018-01-09r1"
     # [END configuration]
    

    See that you were not entering the values for name and config_id inside quotation marks, and also you should not enter your config_id inside brackets.

    I have tried this myself and works alright. If it still doesn't work for you maybe your name is not correct, as the format seems to be:

    • "example-project.appspot.com"

    So if your project id is i.e. my-project-id, then your name would look like:

    "my-project-id.appspot.com"