diff --git a/jupyterhub/objects.py b/jupyterhub/objects.py index 5927a7d8..ed361f8d 100644 --- a/jupyterhub/objects.py +++ b/jupyterhub/objects.py @@ -219,4 +219,5 @@ class Hub(Server): return url_path_join(self.url, 'api') def __repr__(self): - return f"<{self.__class__.__name__} {self.ip}:{self.port}>" + ip = f"[{self.ip}]" if ":" in self.ip else self.ip + return f"<{self.__class__.__name__} {ip}:{self.port}>" diff --git a/jupyterhub/orm.py b/jupyterhub/orm.py index a08b6967..698f5219 100644 --- a/jupyterhub/orm.py +++ b/jupyterhub/orm.py @@ -157,7 +157,8 @@ class Server(Base): spawner = relationship("Spawner", back_populates="server", uselist=False) def __repr__(self): - return f"" + ip = f"[{self.ip}]" if ":" in self.ip else self.ip + return f"" # lots of things have roles diff --git a/jupyterhub/utils.py b/jupyterhub/utils.py index 6ee7de66..fc35ff4f 100644 --- a/jupyterhub/utils.py +++ b/jupyterhub/utils.py @@ -269,15 +269,16 @@ async def wait_for_server(ip, port, timeout=10): """Wait for any server to show up at ip:port.""" if ip in {'', '0.0.0.0', '::'}: ip = '127.0.0.1' - app_log.debug("Waiting %ss for server at %s:%s", timeout, ip, port) + display_ip = f"[{ip}]" if ":" in ip else ip + app_log.debug("Waiting %ss for server at %s:%s", timeout, display_ip, port) tic = time.perf_counter() await exponential_backoff( lambda: can_connect(ip, port), - f"Server at {ip}:{port} didn't respond in {timeout} seconds", + f"Server at {display_ip}:{port} didn't respond in {timeout} seconds", timeout=timeout, ) toc = time.perf_counter() - app_log.debug("Server at %s:%s responded in %.2fs", ip, port, toc - tic) + app_log.debug("Server at %s:%s responded in %.2fs", display_ip, port, toc - tic) async def wait_for_http_server(url, timeout=10, ssl_context=None):