Troubleshooting Cloud Endpoints on Compute Engine

This document presents troubleshooting techniques for Google Cloud Endpoints deployments on Compute Engine.

Deploying on Compute Engine without Docker

If you are having problems deploying Cloud Endpoints on Compute Engine, you may need to reinstall the Cloud Endpoints package. To do this, follow these steps:

  1. SSH into your virtual machine instance:

    gcloud config set project [YOUR_PROJECT_ID]
    gcloud compute ssh [INSTANCE_NAME]
    

    Replace [YOUR_PROJECT_ID] and [INSTANCE_NAME] with your project ID and virtual machine instance name, respectively. Do not include the square brackets.

  2. Run the following commands:

    export CLOUD_ENDPOINTS_REPO="google-cloud-endpoints-jesse"
    echo "deb http://packages.cloud.google.com/apt $CLOUD_ENDPOINTS_REPO main" |
    sudo tee /etc/apt/sources.list.d/google-cloud-endpoints.list
    curl --silent https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo
    apt-key add -
    sudo apt-get update && sudo apt-get install endpoints-runtime
    
  3. Edit /etc/default/nginx and make sure ESP/nginx is configured correctly:

    • The port nginx should listen is configured with the PORT variable. For example, if nginx should listen on port 80, use:

      PORT=80

    • Other ESP options are configured with the DAEMON_ARGS variable. These options are passed directly to the start_esp script. For example, if nginx should expose an HTTPS interface on port 443, use:

      DAEMON_ARGS="--ssl_port=443"

  4. Restart ESP/nginx:

    sudo service nginx restart
    

You have installed the Cloud Endpoints and restarted the Extensible Service Proxy service.

Deploying on Compute Engine with Docker

If you are having problems deploying Cloud Endpoints in a Docker container on Compute Engine, follow these steps to start the Docker container from the command line:

  1. SSH into your virtual machine:

    gcloud config set project [YOUR_PROJECT_ID]
    
    gcloud compute ssh [INSTANCE_NAME]
    

    Replace [YOUR_PROJECT_ID] and [INSTANCE_NAME] with your project ID and virtual machine instance name, respectively. Do not include the square brackets.

  2. Start the Docker container:

    sudo docker run -d -p 80:8080 --link=echo:echo
    
    gcr.io/endpoints-release/endpoints-runtime:latest -s ${SERVICE_NAME} -v ${SERVICE_VERSION} -a echo:8081
    

You have started a Docker container that is running Cloud Endpoints.

Viewing logs

You can troubleshoot problems by looking at the Cloud Endpoints Runtime log. To view the log, follow these steps:

  1. SSH into your virtual machine

    gcloud config set project [YOUR_PROJECT_ID]
    
    gcloud compute ssh [INSTANCE_NAME]
    

    Replace [YOUR_PROJECT_ID] and [INSTANCE_NAME] with your project ID and virtual machine instance name, respectively. Do not include the square brackets.

  2. View the nginx error log

    If you are running endpoints-runtime on a raw VM:

    tail -f /var/log/nginx/error.log
    

    If you are running endpoints-runtime within Docker:

    docker ps
    
    docker logs [CONTAINER_NAME]
    

    Replace [CONTAINER_NAME] with the name of your container. Do not include the square brackets.

Accessing the Endpoints status page

If you set rollout_strategy to managed when you started ESP, and you need to find out the configuration ID that an instance of ESP is using, the Endpoints status page has the information.

To access the Endpoints status page:

  1. SSH into your virtual machine.

  2. Run the following command to get the name of the ESP container (typically the container name is esp):

      docker ps
    
  3. Run the following command to get a bash shell in the container:

      docker exec -it [ESP_CONTAINER_NAME] /bin/bash
    

    Replace [ESP_CONTAINER_NAME] with the name of the ESP container from the previous step.

  4. Install curl.

  5. Enter the following:

     curl http://localhost:9090/endpoints_status
    

You will see something like the following:

      "serviceConfigRollouts": {
          "rolloutId": "2017-08-09r27",
          "percentages": {
               "2017-08-09r26": "100"
          }
      }

The value in the rolloutId is the service configuration ID that ESP is using. To make sure ESP is using the same configuration as Cloud Endpoints, see Getting the Service Name and Configuration ID.

Send feedback about...

Cloud Endpoints with OpenAPI