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

add hub_url_local as hub_url currently represents both public and local #994

Merged
merged 5 commits into from
Oct 31, 2020

Conversation

manics
Copy link
Member

@manics manics commented Nov 2, 2019

I don't know if this is useful so opening it for comments.

I just ran Binderhub on a misconfigured test system where external ingress is limited by IP range. Unfortunately the IP range didn't include itself 😀

BinderHub uses the external JupyterHub API instead of the internal K8s service. Obviously the firewall will be fixed, but is this potentially useful anyway?

@manics manics changed the title WIP: Allow different internal and public hub_url Allow different internal and public hub_url Nov 27, 2019
@manics manics marked this pull request as ready for review November 27, 2019 18:57
@manics manics changed the title Allow different internal and public hub_url [MRG] Allow different internal and public hub_url May 22, 2020
@manics
Copy link
Member Author

manics commented May 22, 2020

Based on #1101 this problem is not unique to my test cluster!

@@ -84,7 +84,8 @@ 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)
hub_url = urlparse(c.BinderHub.hub_url_public if 'hub_url_public' in c.BinderHub
else c.BinderHub.hub_url)
Copy link
Member

@consideRatio consideRatio Oct 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can make hub_url_public have a @default decorated function returning self.hub_url? I think this logic is too messy to use whenever we want to use hub_url_public, so we don't have to duplicate logic about this.

@consideRatio
Copy link
Member

@manics I want to resurrect my work to make BinderHub support automatic HTTPS acquisition using z2jh, and I'll need this if I recall correctly. If you resolve the merge conflicts I'll review this and help it get merged.

@consideRatio
Copy link
Member

I think a key point of review for this PR regards if we want to assume hub_url is a local URL and add a hub_url_public option, or assume it is a public url, and add a hub_url_local option.

From what I see in #1139 and https://binderhub.readthedocs.io/en/latest/zero-to-binderhub/setup-binderhub.html#connect-binderhub-and-jupyterhub, I think perhaps it is better to add a hub_url_local and assume hub_url to be a public path. What do you think?

@bitnik perhaps you have some input about this?

@manics
Copy link
Member Author

manics commented Oct 29, 2020

@consideRatio I'm glad it's useful for more than just me 😄 . I'll resolve the conflicts and try your default suggestion. I don't have any preference on whether to add hub_url_public or hub_url_local.

@consideRatio
Copy link
Member

consideRatio commented Oct 29, 2020

Lets go with hub_url_local, making hub_url become _public implicitly which it seems documented to be used as currently.

Thank you for your work on this @manics ❤️

@bitnik
Copy link
Collaborator

bitnik commented Oct 30, 2020

Lets go with hub_url_local, making hub_url become _public implicitly which it seems documented to be used as currently.

I dont have anything to add on, and I agree with @consideRatio

@consideRatio consideRatio changed the title [MRG] Allow different internal and public hub_url add hub_url_local as hub_url currently represents both public and local Oct 30, 2020
@manics manics marked this pull request as draft October 30, 2020 17:15
@manics
Copy link
Member Author

manics commented Oct 30, 2020

I've rebased and updated the PR to use hub_url_local. I'm testing at the moment so I've marked this as a draft.

Copy link
Member

@consideRatio consideRatio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent! I have verified this matches my old implementation as well.

For reference, my motivation was described something like this innotes I found.

hub_url_local introduced to solve an issue:

hub_url is used in launcher.py, in there it needs to be a public url because it will send that to the BinderHub visitor that is to get an URL for the JupyterHub session. It also needs to be an URL reachable from the binderhub itself wherever it is running. This is not always possible to accomplish, for example when setting up a autohttps test environment against a dummy ACME server.

So, this PR solves a problem for my CI testing an upcoming pr about automatic HTTPS cert acquisition.

@manics manics marked this pull request as ready for review October 30, 2020 22:23
@manics
Copy link
Member Author

manics commented Oct 30, 2020

I added one more commit. I've only partially tested this because k8s broke for unrelated reasons, but I think the PR is ready for review, especially since you already understand what's going on.

@@ -98,7 +98,7 @@ spec:
key: "binder.hub-token"
{{- if .Values.config.BinderHub.auth_enabled }}
- name: JUPYTERHUB_API_URL
value: {{ (print (.Values.config.BinderHub.hub_url | trimSuffix "/") "/hub/api/") }}
value: {{ (print (.Values.config.BinderHub.hub_url_local | default .Values.config.BinderHub.hub_url | trimSuffix "/") "/hub/api/") }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch adding this as well!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If auth_enabled, this URL is required to be mounted as an env var? Hmmm? Is this because the JupyterHub imported HubOAuth classes looks for this URL or similar?

Ah yes it seems so, this could been configured with c.HubAuth.api_url = c.BinderHub.hub_url_local someplace instead, because JUPYTERHUB_API_URL serves the purpose of a default value for the c.HubAuth.api_url traitlet.

It seems like...

  • JUPYTERHUB_API_URL can be configured with c.HubAuth.api_url
  • JUPYTERHUB_BASE_URL can be configured with c.HubAuth.hub_prefix
  • JUPYTERHUB_CLIENT_ID can be configured with c.HubOAuth.oauth_client_id
  • JUPYTERHUB_OAUTH_CALLBACK_URL can be configured with c.HubOAuth.oauth_redirect_uri

Well, okay, let's configure them through environment variables.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@consideRatio I was confused by the apparent duplication between config and env-vars too. I only discovered the problem when deploying it to a test system.

@consideRatio consideRatio merged commit 7e04ad4 into jupyterhub:master Oct 31, 2020
yuvipanda pushed a commit to jupyterhub/helm-chart that referenced this pull request Oct 31, 2020
@manics manics deleted the hub_url_public branch October 31, 2020 11:40
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.

3 participants