Merge pull request #6815 from ryanpetrello/fix-rdb

fix the `make rdb` debugging tool
This commit is contained in:
Ryan Petrello
2017-06-29 15:53:05 -04:00
committed by GitHub
2 changed files with 11 additions and 7 deletions

View File

@@ -8,7 +8,6 @@ NODE ?= node
NPM_BIN ?= npm NPM_BIN ?= npm
DEPS_SCRIPT ?= packaging/bundle/deps.py DEPS_SCRIPT ?= packaging/bundle/deps.py
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
DOCKER_HOST_IP=`python -c "import socket; print(socket.gethostbyname(socket.gethostname()))"`
GCLOUD_AUTH ?= $(shell gcloud auth print-access-token) GCLOUD_AUTH ?= $(shell gcloud auth print-access-token)
# NOTE: This defaults the container image version to the branch that's active # NOTE: This defaults the container image version to the branch that's active
@@ -953,13 +952,13 @@ docker-isolated:
# Docker Compose Development environment # Docker Compose Development environment
docker-compose: docker-auth docker-compose: docker-auth
DOCKER_HOST_IP=$(DOCKER_HOST_IP) TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose.yml up --no-recreate tower TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose.yml up --no-recreate tower
docker-compose-cluster: docker-auth docker-compose-cluster: docker-auth
DOCKER_HOST_IP=$(DOCKER_HOST_IP) TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose-cluster.yml up TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose-cluster.yml up
docker-compose-test: docker-auth docker-compose-test: docker-auth
cd tools && DOCKER_HOST_IP=$(DOCKER_HOST_IP) TAG=$(COMPOSE_TAG) docker-compose run --rm --service-ports tower /bin/bash cd tools && TAG=$(COMPOSE_TAG) docker-compose run --rm --service-ports tower /bin/bash
docker-compose-build: tower-devel-build tower-isolated-build docker-compose-build: tower-devel-build tower-isolated-build
@@ -983,10 +982,10 @@ docker-refresh: docker-clean docker-compose
# Docker Development Environment with Elastic Stack Connected # Docker Development Environment with Elastic Stack Connected
docker-compose-elk: docker-auth docker-compose-elk: docker-auth
DOCKER_HOST_IP=$(DOCKER_HOST_IP) TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose.yml -f tools/elastic/docker-compose.logstash-link.yml -f tools/elastic/docker-compose.elastic-override.yml up --no-recreate TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose.yml -f tools/elastic/docker-compose.logstash-link.yml -f tools/elastic/docker-compose.elastic-override.yml up --no-recreate
docker-compose-cluster-elk: docker-auth docker-compose-cluster-elk: docker-auth
DOCKER_HOST_IP=$(DOCKER_HOST_IP) TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose-cluster.yml -f tools/elastic/docker-compose.logstash-link-cluster.yml -f tools/elastic/docker-compose.elastic-override.yml up --no-recreate TAG=$(COMPOSE_TAG) docker-compose -f tools/docker-compose-cluster.yml -f tools/elastic/docker-compose.logstash-link-cluster.yml -f tools/elastic/docker-compose.elastic-override.yml up --no-recreate
clean-elk: clean-elk:
docker stop tools_kibana_1 docker stop tools_kibana_1

View File

@@ -155,9 +155,14 @@ class CustomPdb(Rdb):
return Rdb.displayhook(self, obj) return Rdb.displayhook(self, obj)
def get_avail_port(self, *args, **kwargs): def get_avail_port(self, *args, **kwargs):
try:
socket.gethostbyname('docker.for.mac.localhost')
host = 'docker.for.mac.localhost'
except:
host = os.popen('ip route').read().split(' ')[2]
sock, port = Rdb.get_avail_port(self, *args, **kwargs) sock, port = Rdb.get_avail_port(self, *args, **kwargs)
socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto( socket.socket(socket.AF_INET, socket.SOCK_DGRAM).sendto(
str(port), ('dockerhost', 6899) str(port), (host, 6899)
) )
return (sock, port) return (sock, port)