Error when setting up ENDPOINTS_SERVICE_NAME

499 views
Skip to first unread message

Nicola Salvo

unread,
Sep 6, 2019, 12:29:35 PM9/6/19
to Google Cloud Endpoints
Hi all,

I'm using ESP with Cloud Run. I have deployed it successfully on a project a while back, and today tried to use the same commands and swagger definition to deploy on a different environment. 
The steps I have taken are (all on an empty project, with all services enabled, and running as Project Owner) :

1) gcloud beta run deploy clr-$ENVIRONMENT_NAME-run-endpoint-api \
    --allow-unauthenticated \
    --platform managed \
    --project=$PROJECT_NAME

2) export  ENDPOINTS_SERVICE_NAME= this was taken from the output provided by the previous command and is in the format of clr-test-run-endpoint-api-RANDOM
3) gcloud endpoints services deploy functions-swagger.yaml   --project $PROJECT_NAME .  where functions-swagger.yaml looks like:

swagger"2.0"
info:
  titleTest Cloud Endpoints URL Shortner
  description:  Test API on Cloud Endpoints for CRL URL Shortner
  version1.0.0
schemes:
  - https
produces:
  - application/json

paths:
  /mypath:
    options:
      summarymy summary
      operationIdmyoperation
      x-google-backend:
        address: PATH TO CLOUDFUNCTION
      responses:
        '204':
          descriptionOK 

4) gcloud beta run services update clr-$ENVIRONMENT_NAME-run-endpoint-api  \
   --set-env-vars ENDPOINTS_SERVICE_NAME=$ENDPOINTS_SERVICE_NAME \
   --platform managed \
   --project $PROJECT_NAME

Once at point 4, I get the following error:

Deploying... Cloud Run error: Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable. Logs for this
revision might contain more information.

Do you have any idea what's wrong with my configuration ? Similar commands in the past used to work, so I suspect something might have changed in either Cloud Run or Cloud Endpoints ? 

Thanks in advance

Nicola 



Wayne Zhang

unread,
Sep 6, 2019, 1:14:24 PM9/6/19
to Google Cloud Endpoints
One thing I can think of is step3.  It may have failed.  ENDPOINTS_SERVICE_NAME has to be unique globally.  You may have used it in your previous project. 
Otherwise please check Cloud Run logs,  it may provide more hints.

Nicola Salvo

unread,
Sep 9, 2019, 5:54:02 AM9/9/19
to Google Cloud Endpoints
Hi Thanks for your reply! 
I have created a new Cloud Run manually, and specified:


in the swagger definition, which now should be unique. 

To avoid issues with the command line I have now manually tried to set the 

ENDPOINTS_SERVICE_NAME

on Cloud Run to the same value (crl-dev-manual-cloudrun-XXXX-uc.a.run.app). The message I get on the log, is: 

2019-09-09 10:39:22.896 BST
INFO:Fetching an access token from the metadata service
2019-09-09 10:39:22.913 BST
INFO:Fetching the service config ID from the rollouts service
2019-09-09 10:39:22.961 BST
ERROR:Fetching rollouts failed (status code 403, reason Forbidden, url https://servicemanagement.googleapis.com/v1/services/crl-dev-manual-cloudrun-stkdsnh63a-uc.a.run.app/rollouts?filter=status=SUCCESS)
2019-09-09 10:39:23.118 BST
Container called exit(1).

I have also tried to change the the service account to a one with Project Owner access, but still no joy. 

Am I correct assuming that ENDPOINTS_SERVICE_NAME should be the same as the Cloud Run URI ? 

Any help to solve the issue is appreciated, as this is stopping me to deploy the rest of the code which depends on ESP to expose the APIs

Thanks in advance

Nicola

Wayne Zhang

unread,
Sep 9, 2019, 12:16:55 PM9/9/19
to Nicola Salvo, Google Cloud Endpoints
It seems that your Endpoint service:  crl-dev-manual-cloudrun-stkdsnh63a-uc.a.run.app is deployed at project A,   but you run the ESP cloud run in project B.   Project B doesn't have  credentials to get the service config from project A.

When you use "gcloud endpoints service deploy openapi.yaml --project A"    Your deploy.yaml has host:  crl-dev-manual-cloudrun-stkdsnh63a-uc.a.run.app
That endpoint service was owned by project A.   You can use 
"gcloud endpoints services list --project A" to verify it.

When you use

gcloud beta run deploy CLOUD_RUN_SERVICE_NAME \
    --image="gcr.io/endpoints-release/endpoints-runtime-serverless
    .... --project B"

This is the project ESP is run on in Cloud Run.  It seems you are using different project.  This project could not use the service owned by project A
This two project has to be matched.


The above terms reflect a potential business arrangement, are provided solely as a basis for further discussion, and are not intended to be and do not constitute a legally binding obligation. No legally binding obligations will be created, implied, or inferred until an agreement in final form is executed in writing by all parties involved.

This email may be confidential or privileged. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let us know that it has gone to the wrong person. 

Cloudreach Europe Limited is registered in England and Wales with the registered office at Saffron House, 6-10 Kirby Street, London, EC1N 8TS and registration number 06975407.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/d23d36dc-1f67-4101-a579-a82c131d453e%40googlegroups.com.

Nicola Salvo

unread,
Sep 13, 2019, 5:25:27 AM9/13/19
to Google Cloud Endpoints
Hi Wayne,

Apologies about the late reply, I have been busy with something else. Indeed I'm using two different projects, but I believe ESP and Run are on the same one, while the other project is used for Cloud functions. I checked and both were on the same project.

Anyway, I kept looking and realised where the problem was. The services necessary were not enabled. I managed to make it work, by:

gcloud services enable servicemanagement.googleapis.com --project=$PROJECT_NAME
gcloud services enable servicecontrol.googleapis.com --project=$PROJECT_NAME
gcloud services enable endpoints.googleapis.com    --project=$PROJECT_NAME

which I didn't have enabled, as the project was new. So probably if you would like to replicate, you can create a new project without the above services enabled and probably get the same result. 

It would be great, if similar to other gcloud commands, if the service is not enabled an error is raised before even attempting the execution.

Thanks for the help

Nicola

On Monday, 9 September 2019 18:16:55 UTC+2, Wayne Zhang wrote:
It seems that your Endpoint service:  crl-dev-manual-cloudrun-stkdsnh63a-uc.a.run.app is deployed at project A,   but you run the ESP cloud run in project B.   Project B doesn't have  credentials to get the service config from project A.

When you use "gcloud endpoints service deploy openapi.yaml --project A"    Your deploy.yaml has host:  crl-dev-manual-cloudrun-stkdsnh63a-uc.a.run.app
That endpoint service was owned by project A.   You can use 
"gcloud endpoints services list --project A" to verify it.

When you use

gcloud beta run deploy CLOUD_RUN_SERVICE_NAME \
    --image="gcr.io/endpoints-release/endpoints-runtime-serverless
    .... --project B"

This is the project ESP is run on in Cloud Run.  It seems you are using different project.  This project could not use the service owned by project A
This two project has to be matched.


To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

Wayne Zhang

unread,
Sep 13, 2019, 12:14:02 PM9/13/19
to Nicola Salvo, Google Cloud Endpoints
Cool.  I am glad to hear that you solved the problem.   Thanks.   -Wayne

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
The above terms reflect a potential business arrangement, are provided solely as a basis for further discussion, and are not intended to be and do not constitute a legally binding obligation. No legally binding obligations will be created, implied, or inferred until an agreement in final form is executed in writing by all parties involved.

This email may be confidential or privileged. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let us know that it has gone to the wrong person. 

Cloudreach Europe Limited is registered in England and Wales with the registered office at Saffron House, 6-10 Kirby Street, London, EC1N 8TS and registration number 06975407.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/efb3419d-7202-4cd0-b647-dc548e59c98a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages