From fa83000f073abc1966eafd4093bcd84a0efb1a50 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Mon, 22 Jul 2024 14:36:23 +0200 Subject: [PATCH] feat(debug): add manhole debugging Signed-off-by: Raito Bezarius --- buildbot_nix/__init__.py | 5 +++++ nix/coordinator.nix | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/buildbot_nix/__init__.py b/buildbot_nix/__init__.py index aa66e54..f43542c 100644 --- a/buildbot_nix/__init__.py +++ b/buildbot_nix/__init__.py @@ -824,8 +824,10 @@ class GerritNixConfigurator(ConfiguratorBase): prometheus_config: dict[str, int | str] | None = None, binary_cache_config: dict[str, str] | None = None, auth_method: AuthBase | None = None, + manhole: Any = None, ) -> None: super().__init__() + self.manhole = manhole self.allowed_origins = allowed_origins self.gerrit_server = gerrit_server self.gerrit_user = gerrit_user @@ -860,6 +862,9 @@ class GerritNixConfigurator(ConfiguratorBase): worker_config = json.loads(read_secret_file(self.nix_workers_secret_name)) worker_names = [] + if self.manhole is not None: + config["manhole"] = self.manhole + config.setdefault("projects", []) config.setdefault("secretsProviders", []) config.setdefault("www", { diff --git a/nix/coordinator.nix b/nix/coordinator.nix index 82b3ee5..d474d07 100644 --- a/nix/coordinator.nix +++ b/nix/coordinator.nix @@ -7,6 +7,9 @@ let inherit (lib) filterAttrs; cfg = config.services.buildbot-nix.coordinator; + debuggingManhole = if cfg.debugging.enable then + "manhole.TelnetManhole(${toString cfg.debugging.port}, 'admin', 'admin')" + else "None"; in { options = { @@ -28,6 +31,14 @@ in description = "List of local remote builders machines associated to that Buildbot instance"; }; + debugging = { + enable = lib.mkEnableOption "manhole's buildbot debugging on localhost using `admin:admin`"; + port = lib.mkOption { + type = lib.types.port; + default = 15000; + }; + }; + oauth2 = { name = lib.mkOption { type = lib.types.str; @@ -216,6 +227,7 @@ in extraImports = '' from datetime import timedelta from buildbot_nix import GerritNixConfigurator, read_secret_file, make_oauth2_method, OAuth2Config, assemble_secret_file_path + from buildbot import manhole # TODO(raito): make me configurable from the NixOS module. # how? @@ -257,7 +269,8 @@ in auth_method=CustomOAuth2(${builtins.toJSON cfg.oauth2.clientId}, read_secret_file('buildbot-oauth2-secret'), autologin=True - ) + ), + manhole=${debuggingManhole} ) '' ];