Skip to content

Commit ef98667

Browse files
committed
Merge branch 'master' of ssh://github.com/jupyterhub/binderhub into main
2 parents 8a2f812 + a00bbbb commit ef98667

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+865
-247
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
name: "CodeQL"
7+
8+
on:
9+
push:
10+
branches: [master]
11+
pull_request:
12+
# The branches below must be a subset of the branches above
13+
branches: [master]
14+
schedule:
15+
# At 13:29 on Friday - https://crontab.guru/
16+
- cron: '29 13 * * 5'
17+
18+
jobs:
19+
analyze:
20+
name: Analyze
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
# Override automatic language detection by changing the below list
27+
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
28+
language: ['python', 'javascript']
29+
# Learn more...
30+
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v2
35+
with:
36+
# We must fetch at least the immediate parents so that if this is
37+
# a pull request then we can checkout the head.
38+
fetch-depth: 2
39+
40+
# If this run was triggered by a pull request event, then checkout
41+
# the head of the pull request instead of the merge commit.
42+
- run: git checkout HEAD^2
43+
if: ${{ github.event_name == 'pull_request' }}
44+
45+
# Initializes the CodeQL tools for scanning.
46+
- name: Initialize CodeQL
47+
uses: github/codeql-action/init@v1
48+
with:
49+
languages: ${{ matrix.language }}
50+
# If you wish to specify custom queries, you can do so here or in a config file.
51+
# By default, queries listed here will override any specified in a config file.
52+
# Prefix the list here with "+" to use these queries and those in the config file.
53+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
54+
55+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
56+
# If this step fails, then you should remove it and run the build manually (see below)
57+
- name: Autobuild
58+
uses: github/codeql-action/autobuild@v1
59+
60+
# ℹ️ Command-line programs to run using the OS shell.
61+
# 📚 https://git.io/JvXDl
62+
63+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
64+
# and modify them (or add more) to build your code if your project
65+
# uses a compiled language
66+
67+
#- run: |
68+
# make bootstrap
69+
# make release
70+
71+
- name: Perform CodeQL Analysis
72+
uses: github/codeql-action/analyze@v1

.travis.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1-
dist: xenial
1+
dist: bionic
22
language: python
33
python:
4-
- 3.6
4+
- 3.7
55
git:
66
depth: false
77
services:
88
- docker
9-
sudo: required
109

1110
before_install:
12-
- nvm install 8; nvm use 8
11+
- nvm install 12; nvm use 12
12+
- pip install --upgrade pip setuptools
1313
install:
14-
# need gnutls headers for pycurl
15-
- sudo apt-get -yq install libgnutls28-dev
1614
- export PATH=$PWD/bin:$PATH
17-
- pip install --upgrade pip setuptools
1815
- ./ci/install.sh
1916
- pip install --upgrade -r dev-requirements.txt
2017
- npm install
2118
- npm run webpack
2219
- pip install --upgrade . -r helm-chart/images/binderhub/requirements.txt
20+
# NOTE: The latest docker python package (4.3.0) requires a more modern docker
21+
# version (newer than 18.06.0-ce / API version: 1.38) which is not yet
22+
# available on travis.
23+
# ref: https://github.com/jupyterhub/zero-to-jupyterhub-k8s/pull/1743
24+
- pip install -U "docker~=4.2.0"
2325
- pip freeze
2426

2527
script:
@@ -46,11 +48,12 @@ env:
4648
- TEST=auth
4749
- TEST=helm
4850
global:
49-
- ASYNC_TEST_TIMEOUT=15
50-
- MINIKUBE_VERSION=0.33.1
51-
- KUBE_VERSION=1.13.2
52-
- HELM_VERSION=2.13.0
53-
- CHANGE_MINIKUBE_NONE_USER=true
51+
# minikube version: https://github.com/kubernetes/minikube/releases
52+
- MINIKUBE_VERSION=1.10.1
53+
# kubernetes version: https://github.com/kubernetes/kubernetes/releases
54+
- KUBE_VERSION=1.18.2
55+
# helm version: https://github.com/helm/helm/releases
56+
- HELM_VERSION=2.16.7
5457
- secure: BuO4oUz5YZvWhH919Tk8h3McM60NybLImIwB+0C4cmcDC/Z4uS1Jh8R8UbD3vIkJyjPgd+WuoaYGzzgJfCiS5i5TZZfi5yI0URu67fc044vaS7zSegZWsuN40mP4QNYTb+VdYniav8pqqyPyUpKNbOQ+/YJ+BWrC/ncqSL+P+UR6PE9T3TQ4XDuB45z0B2hhfDWBMpP6KtGae7YOWstIPi8ufiS76jjRzE4ziLqsOSwJRGhRbjJXqdcZeH2d54jUJSzCEGMSo5lxrFL27YOJ6Vuzr0V208AiQe60CyxtAzyiamVoE9U8pYOnv9KRDMeROSdz2HJkGetedNgCHpf0mNUWLZzQ6udzXtKeG2pxKeLDYKSm8Y3GGGa87nWRaWS1dYwCTHLe1r6Jwt6QwuBqqIa0oOMujStTEgbUOLLw5e80kSWqTxb52XnDi5SgOMGNzcylAYJLHFCL5U9ShAyZWGRAy0p7tFycXy44/k7RiqXr6Xur7NuB9bzXkmsDa7qS1t2DXoUA8FlpxfvqaSqVuFSrN16JHQeBOZGEYondQ2NPvi2vNT68Us4saWUxBf8oxF5pctbJYDDOxWpYFq/pza2+Elset9dv5KjCb61qtotLpo4PER4zgvde5/5HRa1CAOJlVfZB1Au3+b1NoVWNnPcwlb2UGut1+bcaDWyPf20=
5558
- secure: uqQrm6T6oGloQIHs1tLtQm3iIZFUtv1lNgtT+oCfYw3MC1CJ5AkKRaClAcVlFVOoCAE1GeCbnkob0i+LkwE+FQ1uw0fH9QyGx0PiEBrT3ilOXtkHvLXzcB/8PqPnIRR+vQnqigX2wsfiy0po99gBeaKiQjfybZ8UVp03M7+peQ4Y/Dxoj0G0nYZPsCo4F5plfdalJQX+ZVi1QlkglTotVxvb8QjrxXUrJ3OgXyVgW5fmkrRY6rWlb7RkSPlxmOhOZ7KM0BghMvox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yeHQQMmdPspilE=

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contributing to BinderHub
22

33
Welcome! As a [Jupyter](https://jupyter.org) project, we follow the
4-
[Jupyter contributor guide](https://jupyter.readthedocs.io/en/latest/contributor/content-contributor.html).
4+
[Jupyter contributor guide](https://jupyter.readthedocs.io/en/latest/contributing/content-contributor.html).
55

66
There are several different setups for developing BinderHub, depending on which
77
parts of it you want to change: the [documentation](#documentation-changes),
@@ -282,7 +282,7 @@ the [BinderHub documentation](https://binderhub.readthedocs.io/en/latest/setup-b
282282

283283
By default, `minikube start` allocates 2GiB of main memory to the
284284
underlying VM, which might be too low to run the builder successfully.
285-
285+
286286
You may run `minikube start --memory 8192` to start Minikube with a 8GiB
287287
VM underneath.
288288

binderhub/app.py

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from .builder import BuildHandler
3131
from .health import HealthHandler
3232
from .launcher import Launcher
33+
from .log import log_request
3334
from .registry import DockerRegistry
3435
from .main import MainHandler, ParameterizedMainHandler, LegacyRedirectHandler
3536
from .repoproviders import (GitHubRepoProvider, GitRepoProvider,
@@ -306,20 +307,34 @@ def _valid_badge_base_url(self, proposal):
306307
config=True
307308
)
308309

310+
build_memory_request = ByteSpecification(
311+
0,
312+
help="""
313+
Amount of memory to request when scheduling a build
314+
315+
0 reserves no memory.
316+
317+
This is used as the request for the pod that is spawned to do the building,
318+
even though the pod itself will not be using that much memory
319+
since the docker building is happening outside the pod.
320+
However, it makes kubernetes aware of the resources being used,
321+
and lets it schedule more intelligently.
322+
""",
323+
config=True,
324+
)
309325
build_memory_limit = ByteSpecification(
310326
0,
311327
help="""
312328
Max amount of memory allocated for each image build process.
313329
314330
0 sets no limit.
315331
316-
This is used as both the memory limit & request for the pod
317-
that is spawned to do the building, even though the pod itself
318-
will not be using that much memory since the docker building is
319-
happening outside the pod. However, it makes kubernetes aware of
320-
the resources being used, and lets it schedule more intelligently.
332+
This is applied to the docker build itself via repo2docker,
333+
though it is also applied to our pod that submits the build,
334+
even though that pod will rarely consume much memory.
335+
Still, it makes it easier to see the resource limits in place via kubernetes.
321336
""",
322-
config=True
337+
config=True,
323338
)
324339

325340
debug = Bool(
@@ -572,43 +587,47 @@ def initialize(self, *args, **kwargs):
572587
with open(schema_file) as f:
573588
self.event_log.register_schema(json.load(f))
574589

575-
self.tornado_settings.update({
576-
"push_secret": self.push_secret,
577-
"image_prefix": self.image_prefix,
578-
"debug": self.debug,
579-
'launcher': self.launcher,
580-
'appendix': self.appendix,
581-
"build_namespace": self.build_namespace,
582-
"build_image": self.build_image,
583-
'build_node_selector': self.build_node_selector,
584-
'build_pool': self.build_pool,
585-
"sticky_builds": self.sticky_builds,
586-
'log_tail_lines': self.log_tail_lines,
587-
'pod_quota': self.pod_quota,
588-
'per_repo_quota': self.per_repo_quota,
589-
'per_repo_quota_higher': self.per_repo_quota_higher,
590-
'repo_providers': self.repo_providers,
591-
'use_registry': self.use_registry,
592-
'registry': registry,
593-
'traitlets_config': self.config,
594-
'google_analytics_code': self.google_analytics_code,
595-
'google_analytics_domain': self.google_analytics_domain,
596-
'about_message': self.about_message,
597-
'banner_message': self.banner_message,
598-
'extra_footer_scripts': self.extra_footer_scripts,
599-
'jinja2_env': jinja_env,
600-
'build_memory_limit': self.build_memory_limit,
601-
'build_docker_host': self.build_docker_host,
602-
'base_url': self.base_url,
603-
'badge_base_url': self.badge_base_url,
604-
"static_path": os.path.join(HERE, "static"),
605-
'static_url_prefix': url_path_join(self.base_url, 'static/'),
606-
'template_variables': self.template_variables,
607-
'executor': self.executor,
608-
'auth_enabled': self.auth_enabled,
609-
'event_log': self.event_log,
610-
'normalized_origin': self.normalized_origin
611-
})
590+
self.tornado_settings.update(
591+
{
592+
"log_function": log_request,
593+
"push_secret": self.push_secret,
594+
"image_prefix": self.image_prefix,
595+
"debug": self.debug,
596+
"launcher": self.launcher,
597+
"appendix": self.appendix,
598+
"build_namespace": self.build_namespace,
599+
"build_image": self.build_image,
600+
"build_node_selector": self.build_node_selector,
601+
"build_pool": self.build_pool,
602+
"sticky_builds": self.sticky_builds,
603+
"log_tail_lines": self.log_tail_lines,
604+
"pod_quota": self.pod_quota,
605+
"per_repo_quota": self.per_repo_quota,
606+
"per_repo_quota_higher": self.per_repo_quota_higher,
607+
"repo_providers": self.repo_providers,
608+
"use_registry": self.use_registry,
609+
"registry": registry,
610+
"traitlets_config": self.config,
611+
"google_analytics_code": self.google_analytics_code,
612+
"google_analytics_domain": self.google_analytics_domain,
613+
"about_message": self.about_message,
614+
"banner_message": self.banner_message,
615+
"extra_footer_scripts": self.extra_footer_scripts,
616+
"jinja2_env": jinja_env,
617+
"build_memory_limit": self.build_memory_limit,
618+
"build_memory_request": self.build_memory_request,
619+
"build_docker_host": self.build_docker_host,
620+
"base_url": self.base_url,
621+
"badge_base_url": self.badge_base_url,
622+
"static_path": os.path.join(HERE, "static"),
623+
"static_url_prefix": url_path_join(self.base_url, "static/"),
624+
"template_variables": self.template_variables,
625+
"executor": self.executor,
626+
"auth_enabled": self.auth_enabled,
627+
"event_log": self.event_log,
628+
"normalized_origin": self.normalized_origin,
629+
}
630+
)
612631
if self.auth_enabled:
613632
self.tornado_settings['cookie_secret'] = os.urandom(32)
614633

binderhub/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ async def get(self):
118118

119119
class VersionHandler(BaseHandler):
120120
"""Serve information about versions running"""
121+
122+
# demote logging of 200 responses to debug-level
123+
log_success_debug = True
124+
121125
async def get(self):
122126
self.set_header("Content-type", "application/json")
123127
self.write(json.dumps(

binderhub/build.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,28 @@ class Build:
3636
API instead of having to invent our own locking code.
3737
3838
"""
39-
def __init__(self, q, api, name, namespace, repo_url, ref, git_credentials, build_image,
40-
image_name, push_secret, memory_limit, docker_host, node_selector,
41-
appendix='', log_tail_lines=100, sticky_builds=False):
39+
40+
def __init__(
41+
self,
42+
q,
43+
api,
44+
name,
45+
*,
46+
namespace,
47+
repo_url,
48+
ref,
49+
build_image,
50+
docker_host,
51+
image_name,
52+
git_credentials=None,
53+
push_secret=None,
54+
memory_limit=0,
55+
memory_request=0,
56+
node_selector=None,
57+
appendix="",
58+
log_tail_lines=100,
59+
sticky_builds=False,
60+
):
4261
self.q = q
4362
self.api = api
4463
self.repo_url = repo_url
@@ -50,6 +69,7 @@ def __init__(self, q, api, name, namespace, repo_url, ref, git_credentials, buil
5069
self.build_image = build_image
5170
self.main_loop = IOLoop.current()
5271
self.memory_limit = memory_limit
72+
self.memory_request = memory_request
5373
self.docker_host = docker_host
5474
self.node_selector = node_selector
5575
self.appendix = appendix
@@ -255,7 +275,7 @@ def submit(self):
255275
volume_mounts=volume_mounts,
256276
resources=client.V1ResourceRequirements(
257277
limits={'memory': self.memory_limit},
258-
requests={'memory': self.memory_limit}
278+
requests={'memory': self.memory_request},
259279
),
260280
env=env
261281
)

0 commit comments

Comments
 (0)