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

support extraFiles for binderhub pod #1472

Merged
merged 4 commits into from
Apr 27, 2022
Merged

Conversation

minrk
Copy link
Member

@minrk minrk commented Apr 25, 2022

imports extraFiles helpers, spec from JupyterHub, applied to the binderhub pod

Possibly more general solution to #1471

- top-level templates is dict of filename: contents, e.g. "page.html": "{% extends "templates/page.html" %}"
- mount custom templates dir in /etc/binderhub/templates

Existing template config already supports this, so it's just making the files available we need.
@minrk
Copy link
Member Author

minrk commented Apr 25, 2022

Hm, we have a problem in CI because it's now impossible to update the helm schema and pass tests, because the same config is passed both to the current and previous version of binderhub.

If the schema weren't so strict (i.e. rejecting addtionalProperties), this would be less of an issue.

Copy link
Member

@choldgraf choldgraf left a comment

Choose a reason for hiding this comment

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

This seems like a nice and relatively lightweight way to add this functionality without increasing our configuration surface area each time we want another page / section to be extensible...though we should probably improve our documentation around how to do this because many people may not be familiar with the template names they should use for over-riding etc...

@consideRatio
Copy link
Member

consideRatio commented Apr 25, 2022

This seems like [hub|singleuser].extraFiles but specialized for templates. Should we go for the even more general approach of extraFiles instead of this?

I'm probably not willing to invest my own time into this effort at the moment so please go ahead with this template specific approach if you think it makes sense. I know for z2jh it was just one use case to mount templates while mounting configuration files etc would also be relevant, due to that we developed this more general support both for the hub pod and user pods. Overall, this feature seems to have been a great success.

- install an extra 'old' yaml config when installing against an old binderhub version
- this file should only exist during PRs that change the schema, delete immediately after merging
@minrk
Copy link
Member Author

minrk commented Apr 25, 2022

This seems like [hub|singleuser].extraFiles but specialized for templates

It is! I actually used your extraFiles implementation as reference. JupyterHub is much more infinitely extensible, so there are more general files that make sense to drop-in, especially files we as chart maintainers don't need to know about. I'm not sure I see a similar arbitrary files use case in BinderHub, so I thought this would be simpler, both to implement (the whole thing is smaller than just the helpers for extraFiles) and use (deployments don't need to know where we put templates). On the other hand, I can imagine expert JupyterHub deployers (and maintainers) liking the familiarity of extraFiles consistently applied everywhere.

@minrk
Copy link
Member Author

minrk commented Apr 25, 2022

This now imports extraFiles exactly as-is (thanks for the links @consideRatio), so the feature is consistent across jupyterhub/binderhub.

@minrk
Copy link
Member Author

minrk commented Apr 25, 2022

FWIW, I couldn't figure out how to add a simple test that would only run on the full k8s case to verify that the custom template has its effect. I did verify it with a manual deploy (haven't yet with extraFiles, will do that tomorrow).

Comment on lines 25 to 32
{{- with include "binderhub.extraFiles.stringData" .Values.extraFiles }}
{{- . | nindent 2 }}
{{- end }}

{{- with include "binderhub.extraFiles.data" .Values.extraFiles }}
data:
{{- . | nindent 2 }}
{{- end }}
Copy link
Member

Choose a reason for hiding this comment

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

Did you know/consider this option? The helpers seems general enough to function without being hard-copied to this helm chart, and are practically available in the helm chart already.

Suggested change
{{- with include "binderhub.extraFiles.stringData" .Values.extraFiles }}
{{- . | nindent 2 }}
{{- end }}
{{- with include "binderhub.extraFiles.data" .Values.extraFiles }}
data:
{{- . | nindent 2 }}
{{- end }}
{{- with include "jupyterhub.extraFiles.stringData" .Values.extraFiles }}
{{- . | nindent 2 }}
{{- end }}
{{- with include "jupyterhub.extraFiles.data" .Values.extraFiles }}
data:
{{- . | nindent 2 }}
{{- end }}

Copy link
Member Author

Choose a reason for hiding this comment

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

I will try that! I thought of it, but then wasn't sure about versions, etc. I will try it that way tomorrow

Copy link
Member

Choose a reason for hiding this comment

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

Since binderhub pins the version of JupyterHub being the dependency, this feels quite safe. Since the helpers are general enough, I'm not worried about having binderhub starting to use this - at least no more worried than needing to update the code in two places if it improves.

Copy link
Member

@manics manics Apr 25, 2022

Choose a reason for hiding this comment

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

Can I just check, is this considered a supported use of Z2JH chart features (which therefore will be maintained in accordance with semver)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have two answers for that:

  1. I would not consider any helpers in any chart public APIs, unless thoroughly documented to be otherwise
  2. I would not consider binderhub an 'external' project, so I'm okay using these kinds of internal utilities across our internal projects, especially with the strict dependency pin we use in binderhub. If jupyterhub ever breaks this, we can vendor the previous version with a copy/paste or update.

Copy link
Member Author

Choose a reason for hiding this comment

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

tested and works great with the imported helpers

Copy link
Member

Choose a reason for hiding this comment

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

I appreciate the answers above about "not documented -> no commitment" and the distinction about what we recommend using to others and what we do internally.

@manics do you see an action point that would make you feel comfortable around this? Perhaps a declaration of intent for how helpers are used in z2jh? I think being explicit about such intent is fine, especially since I'm unsure about what helpers we should couple to be tracked by the changelog etc.

Copy link
Member

Choose a reason for hiding this comment

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

It's related to the idea behind dogfooding: https://en.m.wikipedia.org/wiki/Eating_your_own_dog_food

We know JupyterHub and Z2JH are used and extended by lots of users, many who we have no idea about, and BinderHub is a prime demonstration of how to build on top of Z2JH. If we're running into issues with extending Z2JH then it's probable that others will too. I think we should therefore aim to do whatever we'd tell others to do. I can't tell from this discussion what the feeling was- say it's acceptable for everything else to do this with the proviso that it's not a standard API, or try and keep it hidden from everyone?

Given the time pressure it's fine to merge this, but if the conclusion of the above discussion is that this shouldn't be copied by other applications then maybe create an issue for how to come up with a public solution?

Copy link
Member Author

Choose a reason for hiding this comment

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

Just chiming it that while I don't consider them public now that doesn't mean they necessarily shouldn't be - if we want to support downstream charts using extraFiles, I think the first step is adding them to the z2jh docs.

@consideRatio
Copy link
Member

consideRatio commented Apr 25, 2022

FWIW, I couldn't figure out how to add a simple test that would only run on the full k8s case to verify that the custom template has its effect. I did verify it with a manual deploy (haven't yet with extraFiles, will do that tomorrow).

I've also failed to make a simple test, but here is an overview of what I did in z2jh in case you wish to implement a test like that.

Hm, we have a problem in CI because it's now impossible to update the helm schema and pass tests, because the same config is passed both to the current and previous version of binderhub.

I think this is inevitable to avoid issues during upgrade tests without having separate configurations. This is how I've resolved it in z2jh:

  1. dev-config.yaml is meant for config that works in both latest stable release and current release.
  2. dev-config-local-chart-extra-config.yaml is meant to adjust the dev-config.yaml with additions that is only valid in the latest version.

The GitHub Workflow testing the charts always run a step referencing dev-config.yaml and dev-config-local-chart-extra-config.yaml but sometimes also runs a step installing the stable release before this using only dev-config.yaml.

If the schema weren't so strict (i.e. rejecting addtionalProperties), this would be less of an issue.

Its strictness can be troublesome here, but is one of the key values of the schema I think. Rejecting unrecognized property names has helped a lot of users catch invalid configuration I believe, and also reduced the maintenance by fewer bugs being reported by invalid configuration caused by typos.

more complex, but also more general

helpers are imported from the jupyterhub chart!
@minrk minrk changed the title support custom templates via helm support extraFiles for binderhub pod Apr 26, 2022
@minrk
Copy link
Member Author

minrk commented Apr 26, 2022

I went with a simple test under pytest.mark.remote. It's not 100% correct semantically (remote doesn't mean it's our helm test config), but it is correct practically (those are the tests we run against this config).

@minrk
Copy link
Member Author

minrk commented Apr 26, 2022

Looks like I wasn't quite right about the condition, trying a fix

opt-in test, only run when --helm is given
@minrk
Copy link
Member Author

minrk commented Apr 26, 2022

New test (new helm mark) now runs only when --helm is passed, verifying that extraFiles is working as intended.

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.

LGTM besides comment with regards to removal of pytest mark.

@minrk minrk merged commit 0b49d3a into jupyterhub:master Apr 27, 2022
@minrk minrk deleted the helm-templates branch April 27, 2022 09:44
consideRatio pushed a commit to jupyterhub/helm-chart that referenced this pull request Apr 27, 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.

4 participants