You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by dr...@apache.org on 2017/10/03 23:32:20 UTC
[incubator-openwhisk-devtools] branch master updated: fixing the
issue with container reuse for consecutive invocations (#56)
This is an automated email from the ASF dual-hosted git repository.
dragos pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-devtools.git
The following commit(s) were added to refs/heads/master by this push:
new 5c3ab90 fixing the issue with container reuse for consecutive invocations (#56)
5c3ab90 is described below
commit 5c3ab903759aae23e1f0925c9fe864136049db27
Author: ddragosd <dd...@gmail.com>
AuthorDate: Tue Oct 3 16:32:18 2017 -0700
fixing the issue with container reuse for consecutive invocations (#56)
* auto-discover runc binaries
* only mount runc binary
---
docker-compose/.travis/build.sh | 2 +-
docker-compose/Makefile | 32 +++++++++++++++++++++++++++-----
docker-compose/README.md | 20 ++++++++++++++++++--
docker-compose/docker-compose.yml | 17 +++++++++++------
4 files changed, 57 insertions(+), 14 deletions(-)
diff --git a/docker-compose/.travis/build.sh b/docker-compose/.travis/build.sh
index 6a61d15..8dc41f2 100755
--- a/docker-compose/.travis/build.sh
+++ b/docker-compose/.travis/build.sh
@@ -4,4 +4,4 @@ SCRIPTDIR=$(cd $(dirname "$0") && pwd)
ROOTDIR="$SCRIPTDIR/../"
cd $ROOTDIR
-PATH=$PATH:/usr/local/bin/ make quick-start stop
+PATH=$PATH:/usr/local/bin/ VERBOSE=true make quick-start stop
diff --git a/docker-compose/Makefile b/docker-compose/Makefile
index 16a1aec..1f9ca78 100644
--- a/docker-compose/Makefile
+++ b/docker-compose/Makefile
@@ -6,6 +6,10 @@ WSK_CLI ?= $(PROJECT_HOME)/bin/wsk
OPEN_WHISK_DB_PREFIX ?= local_
+DOCKER_KERNEL ?= $(shell docker version --format "{{.Server.KernelVersion}}")
+RUNC_BINARY ?= $(shell if [[ $(DOCKER_KERNEL) == *-moby || $(DOCKER_KERNEL) == *-boot2docker ]]; then (docker run --rm --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh -c "which runc || which docker-runc"); else (which runc || which docker-runc); fi)
+DOCKER_BINARY ?= $(shell if [[ $(DOCKER_KERNEL) == *-moby || $(DOCKER_KERNEL) == *-boot2docker ]]; then (docker run --rm --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh -c "which docker"); else (which docker); fi)
+
ifndef VERBOSE
.SILENT:
endif
@@ -67,27 +71,45 @@ setup:
cd $(PROJECT_HOME)/ansible/roles/nginx/files/ && ./genssl.sh $(DOCKER_HOST_IP) server
cp $(PROJECT_HOME)/ansible/roles/nginx/files/*.pem ~/tmp/openwhisk/apigateway/ssl
cp -r ./apigateway/* ~/tmp/openwhisk/apigateway/
+ > ~/tmp/openwhisk/local.env
+ printf "DOCKER_BINARY=$(DOCKER_BINARY)\n" >> ~/tmp/openwhisk/local.env
+ printf "RUNC_BINARY=$(RUNC_BINARY)\n" >> ~/tmp/openwhisk/local.env
+ printf "DOCKER_COMPOSE_HOST=$(DOCKER_HOST_IP)\n" >> ~/tmp/openwhisk/local.env
+ printf "DOCKER_REGISTRY=$(DOCKER_REGISTRY)\n" >> ~/tmp/openwhisk/local.env
+ printf "DOCKER_IMAGE_PREFIX=$(DOCKER_IMAGE_PREFIX)\n" >> ~/tmp/openwhisk/local.env
.PHONY: restart
restart: stop rm start-docker-compose
.PHONY: restart-controller
restart-controller:
- DOCKER_COMPOSE_HOST=$(DOCKER_HOST_IP) DOCKER_REGISTRY=$(DOCKER_REGISTRY) DOCKER_IMAGE_PREFIX=$(DOCKER_IMAGE_PREFIX) docker-compose --project-name openwhisk restart controller 2>&1 > ~/tmp/openwhisk/docker-compose.log &
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk stop controller
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk rm controller
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk up controller 2>&1 >> ~/tmp/openwhisk/docker-compose.log &
+ echo "waiting for the controller to see the invoker is 'up' ... "
+ until (curl --silent http://$(DOCKER_HOST_IP):8888/invokers | grep "up"); do printf '.'; sleep 5; done
+
+.PHONY: restart-invoker
+restart-invoker:
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk stop invoker
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk rm invoker
+ echo "waiting for the invoker to be marked 'down' ... "
+ until (curl --silent http://$(DOCKER_HOST_IP):8888/invokers | grep "down"); do printf '.'; sleep 5; done
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk up invoker 2>&1 >> ~/tmp/openwhisk/docker-compose.log &
echo "waiting for the invoker to be marked Healthy ... "
until (curl --silent http://$(DOCKER_HOST_IP):8888/invokers | grep "up"); do printf '.'; sleep 5; done
.PHONY: start-docker-compose
start-docker-compose:
- DOCKER_COMPOSE_HOST=$(DOCKER_HOST_IP) DOCKER_REGISTRY=$(DOCKER_REGISTRY) DOCKER_IMAGE_PREFIX=$(DOCKER_IMAGE_PREFIX) docker-compose --project-name openwhisk up 2>&1 > ~/tmp/openwhisk/docker-compose.log &
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk up 2>&1 > ~/tmp/openwhisk/docker-compose.log &
.PHONY: stop
stop:
- DOCKER_COMPOSE_HOST=$(DOCKER_HOST_IP) DOCKER_REGISTRY=$(DOCKER_REGISTRY) DOCKER_IMAGE_PREFIX=$(DOCKER_IMAGE_PREFIX) docker-compose --project-name openwhisk stop
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk stop
.PHONY: rm
rm:
- DOCKER_COMPOSE_HOST=$(DOCKER_HOST_IP) DOCKER_REGISTRY=$(DOCKER_REGISTRY) DOCKER_IMAGE_PREFIX=$(DOCKER_IMAGE_PREFIX) docker-compose --project-name openwhisk rm
+ $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk rm
.PHONY: init-couchdb
init-couchdb:
@@ -135,7 +157,7 @@ hello-world: create-hello-world-function
echo "$$(tput setaf 4)invoking the function ...$$(tput sgr0)"
res=`$(WSK_CLI) -i action invoke hello --blocking --result` \
&& echo "invokation result:" $$res \
- && (echo $$res | grep "Hello, World") || ($(WSK_CLI) -i action delete hello && exit 1)
+ && (echo $$res | grep "Hello, World") || ($(WSK_CLI) -i action delete hello && tail -n 200 ~/tmp/openwhisk/invoker/logs/invoker-local_logs.log ~/tmp/openwhisk/controller/logs/controller-local_logs.log && exit 1)
echo "$$(tput setaf 1)deleting the function ...$$(tput sgr0)"
$(WSK_CLI) -i action delete hello
diff --git a/docker-compose/README.md b/docker-compose/README.md
index f3208c3..0611a5b 100644
--- a/docker-compose/README.md
+++ b/docker-compose/README.md
@@ -43,16 +43,32 @@ If `PROJECT_HOME` variable is set ( i.e. `PROJECT_HOME=/path/to/openwhisk make q
then the command skips downloading the `master` branch and uses instead the source code found in the `PROJECT_HOME` folder.
This is useful for working with a local clone, making changes to the code, and run it with `docker-compose`.
+## Updating OpenWhisk Invoker or Controller
+
+To update the OpenWhisk Invoker or Controller without restarting everything, run:
+
+```bash
+make restart-invoker
+```
+This command destroys the running Invoker instance, waits for the controller to figure out the invoker is `down`, then it starts a new Invoker, also waiting until it's marked as `up`.
+
+To do the same with the controller run:
+
+```bash
+make restart-controller
+```
+
+
## Troubleshooting
* ```error: Authenticated user does not have namespace 'guest'; set command failed: Get https://localhost:443/api/v1/namespaces: dial tcp [::1]:443: getsockopt: connection refused```
Make sure nothing runs on the above listed ports. Port 80 might be commonly in use by a local httpd for example. On a Mac, use `sudo lsof -i -P` to find out what process runs on a port. You can turn off Internet Sharing under System Settings > Sharing, or try `sudo /usr/sbin/apachectl stop` to stop httpd.
-
+
* ```error: Unable to invoke action 'hello': There was an internal server error. (code 5)```
Look at the logs in `~/tmp/openwhisk` especially `~/tmp/openwhisk/controller/logs/controller-local_logs.log` that might give more information. This can be an indication that the docker environment doesn't work properly (and on Mac you might need to switch to use [Docker for Mac](https://www.docker.com/docker-mac).
-
+
* Check the [issue tracker](https://github.com/apache/incubator-openwhisk-devtools/issues) for more.
# Build
diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
index 84bbadb..bad9335 100644
--- a/docker-compose/docker-compose.yml
+++ b/docker-compose/docker-compose.yml
@@ -1,4 +1,4 @@
-version: '2'
+version: '3'
services:
db:
image: couchdb:1.6
@@ -40,7 +40,8 @@ services:
- db
- kafka
env_file:
- - ./docker-whisk-controller.env
+ - ./docker-whisk-controller.env # env vars shared
+ - ~/tmp/openwhisk/local.env # generated during make setup
environment:
COMPONENT_NAME: controller
PORT: 8888
@@ -66,6 +67,9 @@ services:
invoker:
image: openwhisk/invoker:latest
command: /bin/sh -c "/invoker/bin/invoker 0 >> /logs/invoker-local_logs.log 2>&1"
+ privileged: true
+ pid: "host"
+ userns_mode: "host"
links:
- db:db.docker
- kafka:kafka.docker
@@ -74,6 +78,7 @@ services:
- kafka
env_file:
- ./docker-whisk-controller.env # env vars shared
+ - ~/tmp/openwhisk/local.env # generated during make setup
environment:
COMPONENT_NAME: invoker
SERVICE_NAME: invoker0
@@ -92,16 +97,16 @@ services:
EDGE_HOST: ${DOCKER_COMPOSE_HOST}
EDGE_HOST_APIPORT: 443
- DOCKER_REGISTRY: ${DOCKER_REGISTRY}
- DOCKER_IMAGE_PREFIX: ${DOCKER_IMAGE_PREFIX}
-
INVOKER_CONTAINER_NETWORK: openwhisk_default
- WHISK_API_HOST_NAME: https://${DOCKER_COMPOSE_HOST}
+ WHISK_API_HOST_NAME: ${DOCKER_COMPOSE_HOST}
volumes:
- ~/tmp/openwhisk/invoker/logs:/logs
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker/containers:/containers
+ - ${RUNC_BINARY}:/usr/bin/docker-runc
+ - /run/runc:/run/runc
+ - /sys/fs/cgroup:/sys/fs/cgroup
ports:
- "8085:8085"
--
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].