Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port gateway from notebook #92

Merged
merged 17 commits into from
Sep 27, 2019

Conversation

kevin-bates
Copy link
Member

@kevin-bates kevin-bates commented Sep 23, 2019

Ported (cherry-picked) the following Notebook commits to incorporate gateway support into server (Note: commit ids are relative to Notebook [newest to oldest] for cross-referencing):

a1b133393 Attempt to re-establish websocket connection to Gateway (#4777)
7e50cdc85 Remove verbose debug statement in gateway mode (#4725)
2339e6fa2 Missing yield statement on WebSocketChannelsHandler (#4724)
eb4285ed5 Add keepalive ping on gateway websocket (#4701)
385dc9ae0 Add authorization token to header only if no authorization already (#4701)
0c4518823 Modify/add various timeout values (#4701)
914a3f070 Fix binary message issue when configured to forward to gateway (#4576)
be35a370c gateway: compatibility with tornado 4 (#4449)
46bcf78d6 Update gateway support with recent changes (#4431)
acba19033 Minimize handlers and manager methods (#4161)
f74ef2f69 Move environment variables to SingletonConfigurable (#4161)
060a2b9ae Embed NB2KG into Notebook server (#4161)

Along with the following local commits to complete the integration:

90f22e53c Fix tests on py 2
f003f93ee fixup gateway-url alias
776a6673b Allow tests to influence env
b5a48e2b4 Fix gateway_config url reference
160d9dff2 Rename notebook to server
06eb52491 Update IPythonHandler ref to JupyterHandler

@kevin-bates kevin-bates mentioned this pull request Sep 25, 2019
48 tasks
@Zsailer
Copy link
Member

Zsailer commented Sep 25, 2019

@kevin-bates, is this ready for review or are you still cherry-picking commits?

@kevin-bates
Copy link
Member Author

@Zsailer - it should be ready to go but let me use the checklist in #53 to verify if I missed any. I'll post here once I've updated the list. Thanks!

@kevin-bates
Copy link
Member Author

@Zsailer - the checklist has been verified in #53 and this should be good to go. Thanks!

kevin-bates and others added 17 commits September 25, 2019 17:20
This change alleviates a significant pain-point for consumers of Jupyter
Kernel and Enterprise Gateway projects by embedding the few classes defined
in the NB2KG server extension directly into the Notebook server.  All code
resides in a separate gateway directory and the 'extension' is enabled
via a new configuration option `--gateway-url`.

Renamed classes from those used in standard NB2KG code so that Jupyter
servers using the existing NB2KG extension will still work.

Added test_gateway.py to exercise overridden methods.  It does this by
mocking the call that issues requests to the gateway server.

Updated the _Running a notebook server_ topic to include a description
of this feature.
Created a singleton class `Gateway` to store all configuration options
for a Gateway.  This class also holds some help methods to make it easier
to use the options and determine if the gateway option is enabled.

Updated the NotebookTestBase class to allow for subclasses to infuence
the patched environment as well as command line options via argv.

Added a test to ensure various gateway configuration items can be
set via the environment or command-line.
Eliminated the Kernel and Kernelspec handlers.  The Websocket (ZMQ)
channels handler still remains.  This required turning a few methods
into coroutines in the Notebook server.

Renamed the Gateway config object to GatewayClient in case we want
to extend NB server (probably jupyter_server at that point) with
Gateway server functionality - so an NB server could be a Gateway
client or a server depending on launch settings.

Add code to _replace_ the channels handler rather than rely on position
within the handlers lists.

Updated mock-gateway to return the appropriate form of results.

Updated the session manager tests to use a sync ioloop to call the
now async manager methods.
Convey notebook working directory to the gateway (nb2kg pr-21)
Support retrieval of kernelspec resources from the gateway (nb2kg pr-23)
The connect and request timeout defaults have been updated from 20 to 60
seconds and a default value of 40 has been added for KERNEL_LAUNCH_TIMEOUT.
The code ensures that KERNEL_LAUNCH_TIMEOUT is in the env and that the
value of the request timeout is at least 2 greather than KERNEL_LAUNCH_TIMEOUT.

This PR is port of the NB2KG PRs 35 and 38.
We were missing a yield statement in the deferral of `get()` to
the superclass.  This issue was occurring only when Tornado 6+
was deployed.

Also removed a debug message producing way too much information.
I removed the mirroring 'Receiving' debug statement previously and
didn't realize there's a 'Sending' statement.  This change removes
that statement.

This should be part of the 6.0 release, just not signficant enough
to warrant include in rc1.
If the message is bytes, we should set binary=True
This is a port from NB2KG PR jupyter/nb2kg#33
When notebook (with `--gateway-url` option) lost the connection to
Gateway, notebook didn't connect to Gateway again although the
websocket connection from the client was still alive.

This change recovers the connection to Gateway to prevent this anomaly.

Signed-off-by: Eunsoo Park <esevan.park@gmail.com>
@Zsailer
Copy link
Member

Zsailer commented Sep 27, 2019

LGTM!

@Zsailer Zsailer merged commit 7649e39 into jupyter-server:master Sep 27, 2019
@kevin-bates kevin-bates deleted the port-gateway-from-notebook branch September 27, 2019 21:49
Zsailer pushed a commit to Zsailer/jupyter_server that referenced this pull request Nov 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants