From a23550cb5e42ce955a4530fdf527899dd93d2c2f Mon Sep 17 00:00:00 2001 From: Simon Li Date: Fri, 30 Oct 2020 16:15:47 +0000 Subject: [PATCH] Remove hub_url_public, add hub_url_local --- binderhub/app.py | 15 +++++++++++---- binderhub/launcher.py | 4 ++-- helm-chart/binderhub/files/binderhub_config.py | 3 +-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/binderhub/app.py b/binderhub/app.py index c0c3086ae..6d2402ff9 100755 --- a/binderhub/app.py +++ b/binderhub/app.py @@ -379,14 +379,21 @@ def _default_hub_token(self): config=True, ) - hub_url_public = Unicode( + hub_url_local = Unicode( help=""" - The public base URL of the JupyterHub instance where users will run if different from hub_url + The base URL of the JupyterHub instance for local/internal traffic + + If local/internal network connections from the BinderHub process should access + JupyterHub using a different URL than public/external traffic set this, default + is hub_url """, config=True, ) + @default('hub_url_local') + def _default_hub_url_local(self): + return self.hub_url - @validate('hub_url', 'hub_url_public') + @validate('hub_url', 'hub_url_local') def _add_slash(self, proposal): """trait validator to ensure hub_url ends with a trailing slash""" if proposal.value is not None and not proposal.value.endswith('/'): @@ -585,7 +592,7 @@ def initialize(self, *args, **kwargs): self.launcher = Launcher( parent=self, hub_url=self.hub_url, - hub_url_public=self.hub_url_public, + hub_url_local=self.hub_url_local, hub_api_token=self.hub_api_token, create_user=not self.auth_enabled, ) diff --git a/binderhub/launcher.py b/binderhub/launcher.py index bb4bc4186..dffc8f4b1 100644 --- a/binderhub/launcher.py +++ b/binderhub/launcher.py @@ -34,7 +34,7 @@ class Launcher(LoggingConfigurable): hub_api_token = Unicode(help="The API token for the Hub") hub_url = Unicode(help="The URL of the Hub") - hub_url_public = Unicode(help="The public URL of the Hub if different") + hub_url_local = Unicode(help="The internal URL of the Hub if different") create_user = Bool(True, help="Create a new Hub user") allow_named_servers = Bool( os.getenv('JUPYTERHUB_ALLOW_NAMED_SERVERS', "false") == "true", @@ -241,5 +241,5 @@ async def launch(self, image, username, server_name='', repo_url='', extra_args= format(_server_name, username, e, body)) raise web.HTTPError(500, "Failed to launch image %s" % image) - data['url'] = (self.hub_url_public or self.hub_url) + 'user/%s/%s' % (username, server_name) + data['url'] = self.hub_url + 'user/%s/%s' % (username, server_name) return data diff --git a/helm-chart/binderhub/files/binderhub_config.py b/helm-chart/binderhub/files/binderhub_config.py index 5e55ee625..2dd52a4ea 100644 --- a/helm-chart/binderhub/files/binderhub_config.py +++ b/helm-chart/binderhub/files/binderhub_config.py @@ -84,8 +84,7 @@ def get_value(key, default=None): c.BinderHub.build_namespace = os.environ['BUILD_NAMESPACE'] if c.BinderHub.auth_enabled: - hub_url = urlparse(c.BinderHub.hub_url_public if 'hub_url_public' in c.BinderHub - else c.BinderHub.hub_url) + hub_url = urlparse(c.BinderHub.hub_url) c.HubOAuth.hub_host = '{}://{}'.format(hub_url.scheme, hub_url.netloc) if 'base_url' in c.BinderHub: c.HubOAuth.base_url = c.BinderHub.base_url