-
Notifications
You must be signed in to change notification settings - Fork 38
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
Filter users on the server if possible #22
Conversation
JupyterHub 1.3.0 supports server side filtering of the users with servers in a given state [1]. This should perform better when culling a large number of users since the filtering can happen in the database rather than in the client side script on _all_ users. The idle-culler is currently just calling `GET /users` and filtering out users with pending servers on the client side. This change checks to see if the hub API is new enough for server side `state` filtering and if so, filters the initial set of users to only those who have any ready servers (running, not pending). Furthermore, if `--cull-users` is used we make a second call to `GET /users?state=inactive` to get all users who have _no_ active servers since they would have been filtered out of the initial set (`GET /users?state=ready`). If the jupyterhub API version is not new enough the behavior is the same and we filter client-side. Details on manual testing can be found in the issue comments. [1] https://jupyterhub.readthedocs.io/en/stable/_static/rest-api/index.html#operation--users-get Closes jupyterhub#21
Thanks for submitting your first pull request! You are awesome! 🤗 |
@yuvipanda feel free to make changes on this as necessary. It's probably not the prettiest but works in my local testing against jupyterhub 1.3.0. |
@minrk FYI since you added the server side changes for filtering users by server |
Looks great! |
An example of how this will help, in our
So once we get to jupyterhub 1.3.0 (via z2jh 0.11.x) and newer jupyterhub-idle-culler that should be less of a problem. |
JupyterHub 1.3.0 supports server side filtering of the users with
servers in a given state [1]. This should perform better when culling
a large number of users since the filtering can happen in the database
rather than in the client side script on all users.
The idle-culler is currently just calling
GET /users
and filteringout users with pending servers on the client side.
This change checks to see if the hub API is new enough for server
side
state
filtering and if so, filters the initial set of usersto only those who have any ready servers (running, not pending).
Furthermore, if
--cull-users
is used we make a second call toGET /users?state=inactive
to get all users who have no activeservers since they would have been filtered out of the initial
set (
GET /users?state=ready
).If the jupyterhub API version is not new enough the behavior is
the same and we filter client-side.
Details on manual testing can be found in the issue comments.
[1] https://jupyterhub.readthedocs.io/en/stable/_static/rest-api/index.html#operation--users-get
Closes #21