feat: add buildbot-profiler

This enable the possibility to run buildbot-profiler on a production
system.

This exposes the UI but does not compile properly the JavaScript assets
yet.

Signed-off-by: Raito Bezarius <raito@lix.systems>
This commit is contained in:
raito 2024-10-22 17:13:19 +02:00
parent 1aa37c4b80
commit 0ffae5766b
3 changed files with 48 additions and 2 deletions

View file

@ -954,6 +954,7 @@ class GerritNixConfigurator(ConfiguratorBase):
binary_cache_config: dict[str, str] | None = None, binary_cache_config: dict[str, str] | None = None,
auth_method: AuthBase | None = None, auth_method: AuthBase | None = None,
manhole: Any = None, manhole: Any = None,
enable_profiler: bool = False,
) -> None: ) -> None:
super().__init__() super().__init__()
self.manhole = manhole self.manhole = manhole
@ -977,6 +978,7 @@ class GerritNixConfigurator(ConfiguratorBase):
self.url = url self.url = url
self.prometheus_config = prometheus_config self.prometheus_config = prometheus_config
self.enable_profiler = enable_profiler
if binary_cache_config is not None: if binary_cache_config is not None:
self.binary_cache_config = S3BinaryCacheConfig(**binary_cache_config) self.binary_cache_config = S3BinaryCacheConfig(**binary_cache_config)
@ -1081,6 +1083,9 @@ class GerritNixConfigurator(ConfiguratorBase):
config_dict["www"].setdefault("plugins", {}) config_dict["www"].setdefault("plugins", {})
if self.enable_profiler:
config_dict["www"]["plugins"]["profiler"] = True
if "authz" not in config_dict["www"]: if "authz" not in config_dict["www"]:
config_dict["www"]["authz"] = util.Authz( config_dict["www"]["authz"] = util.Authz(
allowRules=[ allowRules=[

View file

@ -140,6 +140,8 @@ in
}; };
}; };
profiler.enable = lib.mkEnableOption " the profiling of the buildbot instance";
gerrit = { gerrit = {
domain = lib.mkOption { domain = lib.mkOption {
type = lib.types.str; type = lib.types.str;
@ -270,7 +272,8 @@ in
read_secret_file('buildbot-oauth2-secret'), read_secret_file('buildbot-oauth2-secret'),
autologin=True autologin=True
), ),
manhole=${debuggingManhole} manhole=${debuggingManhole},
enable_profiler=${builtins.toJSON cfg.profiler.enable}
) )
'' ''
]; ];
@ -288,7 +291,9 @@ in
(ps.toPythonModule pkgs.buildbot-worker) (ps.toPythonModule pkgs.buildbot-worker)
pkgs.buildbot-plugins.www pkgs.buildbot-plugins.www
(pkgs.python3.pkgs.callPackage ../default.nix { }) (pkgs.python3.pkgs.callPackage ../default.nix { })
] ++ lib.optional cfg.prometheus.enable (pkgs.python3.pkgs.callPackage ./prometheus-plugin.nix { }) ]
++ lib.optional cfg.prometheus.enable (pkgs.python3.pkgs.callPackage ./prometheus-plugin.nix { })
++ lib.optional cfg.profiler.enable (pkgs.python3.pkgs.callPackage ./profiler-plugin.nix { })
); );
}; };

36
nix/profiler-plugin.nix Normal file
View file

@ -0,0 +1,36 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
setuptools,
wheel,
}:
buildPythonPackage rec {
pname = "buildbot-profiler";
version = "1.2.2";
pyproject = true;
src = fetchFromGitHub {
owner = "tardyp";
repo = "buildbot_profiler";
rev = "v${version}";
hash = "sha256-r56Cze0v3gKWKJwRy0BUYz5z8d0g3jerCIu3KreNxUc=";
};
build-system = [
setuptools
wheel
];
pythonImportsCheck = [
"buildbot_profiler"
];
meta = {
description = "";
homepage = "https://github.com/tardyp/buildbot_profiler";
license = lib.licenses.unfree; # FIXME: nix-init did not find a license
maintainers = with lib.maintainers; [ raitobezarius ];
};
}