Skip to content

Commit

Permalink
Allow access from remote hosts
Browse files Browse the repository at this point in the history
The update to Notebook 5.6.0 has code that prevents remote host access.  Since
the entire purpose of Enterprise Gateway is to allow remote host access, we need
to enable the web setting `allow_remote_access` to prevent the 403 exception.

Added a statement to update the jupyter framework files after finding issues
due to older dependencies.

Also increased the timeout for waiting for the docker image startup from 30
to 60 seconds and added the ability to override on the command line using
`PREP_TIMEOUT=n`.
  • Loading branch information
kevin-bates committed Jul 24, 2018
1 parent 9bfa136 commit 78d7af9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ endif
($(SA) $(ENV) && GATEWAY_HOST=$(ITEST_HOST) KERNEL_USERNAME=$(ITEST_USER) nosetests -v enterprise_gateway.itests)
@echo "Run \`docker logs itest\` to see enterprise-gateway log."

PREP_TIMEOUT?=60
docker-prep:
@-docker rm -f itest >> /dev/null
@echo "Starting enterprise-gateway container (run \`docker logs itest\` to see container log)..."
@-docker run -itd -p 8888:8888 -h itest --name itest -v `pwd`/enterprise_gateway/itests:/tmp/byok elyra/enterprise-gateway:$(ENTERPRISE_GATEWAY_TAG) --elyra
@(r="1"; attempts=0; while [ "$$r" == "1" -a $$attempts -lt 30 ]; do echo "Waiting for enterprise-gateway to start..."; sleep 2; ((attempts++)); docker logs itest |grep 'Jupyter Enterprise Gateway at http'; r=$$?; done; if [ $$attempts -ge 30 ]; then echo "Wait for startup timed out!"; exit 1; fi;)
@(r="1"; attempts=0; while [ "$$r" == "1" -a $$attempts -lt $(PREP_TIMEOUT) ]; do echo "Waiting for enterprise-gateway to start..."; sleep 2; ((attempts++)); docker logs itest |grep 'Jupyter Enterprise Gateway at http'; r=$$?; done; if [ $$attempts -ge $(PREP_TIMEOUT) ]; then echo "Wait for startup timed out!"; exit 1; fi;)
9 changes: 9 additions & 0 deletions enterprise_gateway/enterprisegatewayapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,21 @@ def init_configurables(self):

self.personality.init_configurables()

def init_webapp(self):
super(EnterpriseGatewayApp, self).init_webapp()

# As of Notebook 5.6, remote kernels are prevented: https://github.com/jupyter/notebook/pull/3714/ unless
# 'allow_remote_access' is enabled. Since this is the entire purpose of EG, we'll unconditionally set that
# here. Because this is a dictionary, we shouldn't have to worry about older versions as this will be ignored.
self.web_app.settings['allow_remote_access'] = True

def start(self):
"""Starts an IO loop for the application. """

# Note that we *intentionally* reference the KernelGatewayApp so that we bypass
# its start() logic and just call that of JKG's superclass.
super(KernelGatewayApp, self).start()

self.log.info('Jupyter Enterprise Gateway at http{}://{}:{}'.format(
's' if self.keyfile else '', self.ip, self.port
))
Expand Down
1 change: 1 addition & 0 deletions etc/docker/enterprise-gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM elyra/yarn-spark:2.1.0
# Install Enterprise Gateway wheel and kernelspecs
COPY jupyter_enterprise_gateway*.whl /tmp
RUN pip install /tmp/jupyter_enterprise_gateway*.whl && \
pip install --upgrade ipykernel jupyter-client notebook && \
rm -f /tmp/jupyter_enterprise_gateway*.whl

ADD jupyter_enterprise_gateway*.tar.gz /usr/local/share/jupyter/kernels/
Expand Down

0 comments on commit 78d7af9

Please sign in to comment.