python-docs-samples icon indicating copy to clipboard operation
python-docs-samples copied to clipboard

gRPC on GKE tutorial: Python client (bookstore_client.py) cannot connect to the API backend in latest version of grc.io/endpointsv2/python-grpc-bookstore-server

Open aruns99 opened this issue 4 years ago • 15 comments

In which file did you encounter the issue?

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/endpoints/bookstore-grpc/bookstore_server.py

Did you change the file? If so, how?

Overrode the PORT env variable to set it to 8000. Changed https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/endpoints/kubernetes/grpc-bookstore.yaml

image: gcr.io/process-mining-gke/bookstore-grpc-server:latest env: - name: PORT value: "8000"

Describe the issue

This issue is with gRPC on GKE tutorial : https://cloud.google.com/endpoints/docs/grpc/get-started-kubernetes-engine

The python client (bookstore_client.py) can no longer connect to the API backend as the latest docker image build of the API backend (grc.io/endpointsv2/python-grpc-bookstore-server) ends up listening on the port specified by the PORT variable while the proxy (esp) forwards request to port 8000 as specified in the Kubernetes manifest file .

This is likely due to the changes made in https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/endpoints/bookstore-grpc/bookstore_server.py to make it work in Cloud Run which requires that the server listen on the port specified by the PORT environment.

aruns99 avatar Jun 18 '20 21:06 aruns99

@aruns99 Thanks for the report.

The change was introduced with https://github.com/GoogleCloudPlatform/python-docs-samples/pull/2764

It looks like the code uses 8000 if PORT envvar is not set. Then I think everything should work, but I may miss something.

Adding the author of the PR here. @nareddyt WDYT?

tmatsuo avatar Jun 25 '20 16:06 tmatsuo

Maybe in this file, we should use gcr.io/endpointsv2/python-grpc-bookstore-server:2 instead of gcr.io/endpointsv2/python-grpc-bookstore-server:1?

tmatsuo avatar Jun 25 '20 17:06 tmatsuo

For the ESP on GKE tutorial linked by the reported, it asks you to use gcr.io/endpointsv2/python-grpc-bookstore-server:1.

But the issue description above uses gcr.io/process-mining-gke/bookstore-grpc-server:latest. @aruns99, could you clarify where you got this image from? Is this your own backend image?

nareddyt avatar Jun 25 '20 17:06 nareddyt

@tmatsuo tag 2 is for some serverless ESP tutorials (cloud run, cloud functions, etc.).

We kept tag 1 as is for the GKE tutorial. gcr.io/endpointsv2/python-grpc-bookstore-server:1 is the correct one for GCE/GKE.

nareddyt avatar Jun 25 '20 17:06 nareddyt

@nareddyt I generated a new image from source which one would expect to work in either GKE or Cloud Run using gcloud builds submit --tag gcr.io/<PROJECT_ID>/python-grpc-bookstore-server . The fix for GKE is to add PORT=8000 environment variable in endpoints/kubernetes/grpc-bookstore.yaml

aruns99 avatar Jun 26 '20 07:06 aruns99

I see, yes that is a good point. We plan on launching ESPv2 for GKE soon, so I'll update this doc and tutorials with the env var so it works with the latest code.

@tmatsuo can you assign this issue to me? Thanks

nareddyt avatar Jun 26 '20 17:06 nareddyt

@nareddyt what's the latest on this issue?

donmccasland avatar Feb 11 '21 21:02 donmccasland

I have not had a chance to work on it. Have not prioritized it because it's nice to have, but everything works as expected if you follow the documentation.

nareddyt avatar Feb 12 '21 17:02 nareddyt

Okay, lowering priority

donmccasland avatar Feb 23 '21 17:02 donmccasland

Hi @nareddyt, could you please provide an update on this issue? If you don't have time in the next few months to complete this, let us know what we have to do, and my team can make the changes. Thanks!

askmeegs avatar Sep 12 '21 19:09 askmeegs

Sure, I can do this task this week. Thanks for the reminder!

nareddyt avatar Sep 20 '21 17:09 nareddyt

friendly ping @nareddyt

dandhlee avatar Feb 19 '22 23:02 dandhlee