Skip to content

Commit 7c910d8

Browse files
committed
Pass example builder instance to /version /health handlers
BuildExecutor.identifier for BinderHub /version endpoint
1 parent 1899c37 commit 7c910d8

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

binderhub/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,9 @@ def initialize(self, *args, **kwargs):
881881

882882
launch_quota = self.launch_quota_class(parent=self, executor=self.executor)
883883

884+
# Construct a Builder so that we can extract parameters such as the
885+
# configuration or the version string to pass to /version and /health handlers
886+
example_builder = self.build_class(parent=self)
884887
self.tornado_settings.update(
885888
{
886889
"log_function": log_request,
@@ -893,6 +896,7 @@ def initialize(self, *args, **kwargs):
893896
"build_token_check_origin": self.build_token_check_origin,
894897
"build_token_secret": self.build_token_secret,
895898
"build_token_expires_seconds": self.build_token_expires_seconds,
899+
"example_builder": example_builder,
896900
"pod_quota": self.pod_quota,
897901
"per_repo_quota": self.per_repo_quota,
898902
"per_repo_quota_higher": self.per_repo_quota_higher,

binderhub/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ async def get(self):
247247
self.write(
248248
json.dumps(
249249
{
250-
"builder": self.settings["build_image"],
250+
"builder": self.settings["example_builder"].identifier,
251251
"binderhub": binder_version,
252252
}
253253
)

binderhub/build.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ class BuildExecutor(LoggingConfigurable):
101101
config=True,
102102
)
103103

104+
identifier = Unicode(
105+
"",
106+
help=(
107+
"Identifier or other metadata for the builder e.g. repo2docker version. "
108+
"This is included in the BinderHub version endpoint"
109+
),
110+
config=True,
111+
)
112+
104113
def __init__(self, **kwargs):
105114
super().__init__(**kwargs)
106115
self.main_loop = IOLoop.current()
@@ -239,6 +248,10 @@ def _default_namespace(self):
239248
config=True,
240249
)
241250

251+
@default("identifier")
252+
def _default_identifier(self):
253+
return self.build_image
254+
242255
docker_host = Unicode(
243256
"/var/run/docker.sock",
244257
help=(

binderhub/health.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ class KubernetesHealthHandler(HealthHandler):
183183
@at_most_every
184184
async def _get_pods(self):
185185
"""Get information about build and user pods"""
186-
namespace = self.settings["build_namespace"]
187-
k8s = self.settings["kubernetes_client"]
186+
namespace = self.settings["example_builder"].namespace
187+
k8s = self.settings["example_builder"].api
188188
pool = self.settings["executor"]
189189

190190
app_log.info(f"Getting pod statistics for {namespace}")

0 commit comments

Comments
 (0)