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

added remove_named_servers setting for jupyterhub-idle-culler #881

Merged
merged 4 commits into from
May 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/topic/idle-culler.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ the users will not be culled alongside their notebooks and will continue to exis
services.cull.users = False
```

If named servers are in use, they are not removed after being culled.
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 make one edit during the rebase here.

Previously it said If named servers are in use, remove the server after stopping it. which didn't make sense to describe the default value of False for remove_named_servers.


```python
services.cull.remove_named_servers = False
```

## Configuring the idle culler

The available configuration options are:
Expand Down Expand Up @@ -76,6 +82,16 @@ sudo tljh-config set services.cull.max_age <server-max-age>
sudo tljh-config reload
```

### Remove Named Servers

Remove named servers after they are shutdown. Only applies if named servers are
enabled on the hub installation:

```bash
sudo tljh-config set services.cull.remove_named_servers True
sudo tljh-config reload
```

### User culling

In addition to servers, it is also possible to cull the users. This is usually
Expand Down
37 changes: 37 additions & 0 deletions tests/test_configurer.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,43 @@ def test_set_cull_service():
]


def test_cull_service_named():
"""
Test default cull service settings with named server removal
"""
c = apply_mock_config(
{
"services": {
"cull": {
"every": 10,
"cull_users": True,
"remove_named_servers": True,
"max_age": 60,
}
}
}
)

cull_cmd = [
sys.executable,
"-m",
"jupyterhub_idle_culler",
"--timeout=600",
"--cull-every=10",
"--concurrency=5",
"--max-age=60",
"--cull-users",
"--remove-named-servers",
]
assert c.JupyterHub.services == [
{
"name": "cull-idle",
"admin": True,
"command": cull_cmd,
}
]


def test_load_secrets(tljh_dir):
"""
Test loading secret files
Expand Down
3 changes: 3 additions & 0 deletions tljh/configurer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"concurrency": 5,
"users": False,
"max_age": 0,
"remove_named_servers": False,
},
"configurator": {"enabled": False},
},
Expand Down Expand Up @@ -256,6 +257,8 @@ def set_cull_idle_service(config):
cull_cmd += ["--max-age=%d" % cull_config["max_age"]]
if cull_config["users"]:
cull_cmd += ["--cull-users"]
if cull_config["remove_named_servers"]:
cull_cmd += ["--remove-named-servers"]

cull_service = {
"name": "cull-idle",
Expand Down