From 89c1c4574551c0cfa111330bb9803cc28ce419d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 26 Dec 2024 10:05:15 +0100 Subject: [PATCH] if one project cannot be configured, don't crash buildbot Instead log the error with more context. --- buildbot_nix/buildbot_nix/__init__.py | 39 ++++++++++++++------------- buildbot_nix/buildbot_nix/models.py | 4 +-- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/buildbot_nix/buildbot_nix/__init__.py b/buildbot_nix/buildbot_nix/__init__.py index 9cdb94898..72c101d2a 100644 --- a/buildbot_nix/buildbot_nix/__init__.py +++ b/buildbot_nix/buildbot_nix/__init__.py @@ -1799,24 +1799,27 @@ def configure(self, config: dict[str, Any]) -> None: atexit.register(lambda: DB.close() if DB is not None else None) for project in projects: - config_for_project( - config=config, - project=project, - worker_names=worker_names, - nix_supported_systems=self.config.build_systems, - nix_eval_worker_count=self.config.eval_worker_count - or multiprocessing.cpu_count(), - nix_eval_max_memory_size=self.config.eval_max_memory_size, - eval_lock=eval_lock, - post_build_steps=[ - x.to_buildstep() for x in self.config.post_build_steps - ], - job_report_limit=self.config.job_report_limit, - per_repo_effects_secrets=self.config.effects_per_repo_secrets, - failed_builds_db=DB, - branch_config_dict=self.config.branches, - outputs_path=self.config.outputs_path, - ) + try: + config_for_project( + config=config, + project=project, + worker_names=worker_names, + nix_supported_systems=self.config.build_systems, + nix_eval_worker_count=self.config.eval_worker_count + or multiprocessing.cpu_count(), + nix_eval_max_memory_size=self.config.eval_max_memory_size, + eval_lock=eval_lock, + post_build_steps=[ + x.to_buildstep() for x in self.config.post_build_steps + ], + job_report_limit=self.config.job_report_limit, + per_repo_effects_secrets=self.config.effects_per_repo_secrets, + failed_builds_db=DB, + branch_config_dict=self.config.branches, + outputs_path=self.config.outputs_path, + ) + except Exception as e: # noqa: BLE001 + log.failure(f"Failed to configure project {project.name}") config["workers"].extend(worker.LocalWorker(w) for w in SKIPPED_BUILDER_NAMES) diff --git a/buildbot_nix/buildbot_nix/models.py b/buildbot_nix/buildbot_nix/models.py index 3fbdd997e..6ac239bdc 100644 --- a/buildbot_nix/buildbot_nix/models.py +++ b/buildbot_nix/buildbot_nix/models.py @@ -1,5 +1,5 @@ -import re import json +import re from collections.abc import Callable, Mapping from enum import Enum from pathlib import Path @@ -9,8 +9,8 @@ from pydantic import BaseModel, ConfigDict, Field, GetCoreSchemaHandler, TypeAdapter from pydantic_core import CoreSchema, core_schema -from .secrets import read_secret_file from .errors import BuildbotNixError +from .secrets import read_secret_file class InternalError(Exception):