venf2k / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
0 stars 0 forks source link

gcd grpc emulator misbehaving with ipv4/ipv6 listen address #769

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1) Run the (new grpc) gcd emulator inside of any ubuntu w/java-jre 
docker-container, and attempt to forward dockerhost:10000 to 
dockercontainer:8080.
2) Attempt to curl dockerhost:10000, notice that GCD is unreachable.
3) Attempt to curl localhost:8080 from inside the docker container, notice that 
you receive "Ok" (indicating GCD is indeed running):
  docker exec -it <CONTAINER_ID> curl localhost:8080

=== BEGIN EXAMPLE DOCKERFILE ===
# docker build -t test .
# docker run --rm -p 8080-8081:8080-8081 test

FROM java:7-jre

RUN apt-get update
RUN apt-get install -y python curl net-tools socat

RUN wget https://storage.googleapis.com/gcd/tools/gcd-grpc-1.0.0.zip
RUN unzip gcd-grpc-1.0.0.zip

# Does not work
CMD gcd/gcd.sh create test && gcd/gcd.sh start ./test

# Does work (forwarding ipv6->ipv4)
# CMD socat TCP6-LISTEN:8081,fork TCP4:0.0.0.0:8080 & gcd/gcd.sh create test && 
gcd/gcd.sh start ./test
=== END EXAMPLE DOCKERFILE ===

What is the expected output? What do you see instead?

I would expect to be able to reach the gcd 

What is the output of 'gcloud info'?

N/A - new gcd-emulator not part of gcloud packages yet.

Please provide any additional information below.

Thanks for the new grpc implementation! The new emulator may be binding 
addresses in a strange way, as I'm unable to reach it from outside a 
docker-container.

Inside the container, I noticed that it listens on an ipv4 local address, but 
an ipv6 foreign address.

root@10c36b89632f:/mnt/data# netstat -lpne
...
Proto Recv-Q Send-Q Local Address           Foreign Address         State       
User       Inode       PID/Program name
tcp6       0      0 127.0.0.1:8080          :::*                    LISTEN      
0          3165434     26/java

I'm far from an expert here, but enough poking and experimenting indicates that 
may be the source of the problem. When I run (other) grpc services inside 
(other) containers, listening with s.Serve(":1234") I notice that both the 
local and foreign addresses are ipv6, and if I listen on an ipv4 address with 
s.Serve("127.0.0.1:1234"), the foreign address is the ipv4 catch-all of 
0.0.0.0:*.

I also find that I can reach gcd from outside the container if I manually 
forward traffic inside the container from ipv6 port to the ipv4 port gcd 
listens on. e.g.:

socat TCP6-LISTEN:8081,fork TCP4:0.0.0.0:8080

1) Are there any magic flags or env vars to control the bound address?
2) If not, would it possible to either change or provide the ability to modify 
the address the new gcd-grpc emulator listens to?

Thanks!

Original issue reported on code.google.com by came...@vantagesports.com on 20 Apr 2016 at 10:57