From b5681b1ea01b8782deaf7b8924d8a6c86b904d90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 13 Oct 2023 00:38:57 +0200 Subject: [PATCH 1/5] remove incorrect skip if path exists the path might exists also the build failed --- buildbot_nix/buildbot_nix.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/buildbot_nix/buildbot_nix.py b/buildbot_nix/buildbot_nix.py index 1b9ca2c..2e62bac 100644 --- a/buildbot_nix/buildbot_nix.py +++ b/buildbot_nix/buildbot_nix.py @@ -209,12 +209,6 @@ class NixBuildCommand(buildstep.ShellMixin, steps.BuildStep): log: Log = yield self.addLog("nix_error") log.addStderr(f"{attr} failed to evaluate:\n{error}") return util.FAILURE - path = self.getProperty("out_path") - - # FIXME: actually we should check if it exists in the remote machine - if os.path.exists(path): - # build already succeeded - return util.SKIPPED # run `nix build` cmd: remotecommand.RemoteCommand = yield self.makeRemoteShellCommand() From 776a6ea4990721c000be309b87bdaaafb33f4d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 15 Oct 2023 08:36:33 +0200 Subject: [PATCH 2/5] update flakes with a random delay --- buildbot_nix/buildbot_nix.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/buildbot_nix/buildbot_nix.py b/buildbot_nix/buildbot_nix.py index 2e62bac..44b8559 100644 --- a/buildbot_nix/buildbot_nix.py +++ b/buildbot_nix/buildbot_nix.py @@ -3,6 +3,7 @@ import json import multiprocessing import os +import random import signal import sys import uuid @@ -13,19 +14,16 @@ from pathlib import Path from typing import Any from buildbot.configurators import ConfiguratorBase -from buildbot.plugins import reporters, schedulers, secrets, steps, util, worker +from buildbot.plugins import (reporters, schedulers, secrets, steps, util, + worker) from buildbot.process import buildstep, logobserver, remotecommand from buildbot.process.log import Log from buildbot.process.project import Project from buildbot.process.properties import Interpolate, Properties from buildbot.process.results import ALL_RESULTS, statusToString from buildbot.steps.trigger import Trigger -from github_projects import ( # noqa: E402 - GithubProject, - create_project_hook, - load_projects, - refresh_projects, -) +from github_projects import (GithubProject, create_project_hook, # noqa: E402 + load_projects, refresh_projects) from twisted.internet import defer, threads from twisted.python.failure import Failure @@ -579,6 +577,11 @@ def config_for_project( nix_supported_systems: list[str], nix_eval_max_memory_size: int, ) -> Project: + # get a deterministic jitter for the project + random.seed(project.name) + # don't run all projects at the same time + jitter = random.randint(1, 60) * 60 + config["projects"].append(Project(project.name)) config["schedulers"].extend( [ @@ -623,13 +626,11 @@ def config_for_project( builderNames=[f"{project.name}/update-flake"], buttonName="Update flakes", ), - # updates flakes once a weeek - schedulers.NightlyTriggerable( + # updates flakes once a week + schedulers.Periodic( name=f"{project.id}-update-flake-weekly", builderNames=[f"{project.name}/update-flake"], - hour=3, - minute=0, - dayOfWeek=6, + periodicBuildTimer=24*60*60*7 + jitter, ), ] ) From 2409fc9c91d7b3042c11d475524ff552c4a1eb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 15 Oct 2023 08:36:45 +0200 Subject: [PATCH 3/5] reload github projects every 12 hours --- buildbot_nix/buildbot_nix.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/buildbot_nix/buildbot_nix.py b/buildbot_nix/buildbot_nix.py index 44b8559..1afdde0 100644 --- a/buildbot_nix/buildbot_nix.py +++ b/buildbot_nix/buildbot_nix.py @@ -14,16 +14,19 @@ from pathlib import Path from typing import Any from buildbot.configurators import ConfiguratorBase -from buildbot.plugins import (reporters, schedulers, secrets, steps, util, - worker) +from buildbot.plugins import reporters, schedulers, secrets, steps, util, worker from buildbot.process import buildstep, logobserver, remotecommand from buildbot.process.log import Log from buildbot.process.project import Project from buildbot.process.properties import Interpolate, Properties from buildbot.process.results import ALL_RESULTS, statusToString from buildbot.steps.trigger import Trigger -from github_projects import (GithubProject, create_project_hook, # noqa: E402 - load_projects, refresh_projects) +from github_projects import ( # noqa: E402 + GithubProject, + create_project_hook, + load_projects, + refresh_projects, +) from twisted.internet import defer, threads from twisted.python.failure import Failure @@ -630,7 +633,7 @@ def config_for_project( schedulers.Periodic( name=f"{project.id}-update-flake-weekly", builderNames=[f"{project.name}/update-flake"], - periodicBuildTimer=24*60*60*7 + jitter, + periodicBuildTimer=24 * 60 * 60 * 7 + jitter, ), ] ) @@ -734,12 +737,20 @@ class NixConfigurator(ConfiguratorBase): self.github.project_cache_file, ) ) - config["schedulers"].append( - schedulers.ForceScheduler( - name="reload-github-projects", - builderNames=["reload-github-projects"], - buttonName="Update projects", - ) + config["schedulers"].extend( + [ + schedulers.ForceScheduler( + name="reload-github-projects", + builderNames=["reload-github-projects"], + buttonName="Update projects", + ), + # project list twice a day + schedulers.Periodic( + name="reload-github-projects-bidaily", + builderNames=["reload-github-projects"], + periodicBuildTimer=12 * 60 * 60, + ), + ] ) config["services"] = config.get("services", []) config["services"].append( From a553fdfa345a507d99fcf1a411cf0da7a3a6bd96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 15 Oct 2023 11:26:09 +0200 Subject: [PATCH 4/5] use nix-eval-jobs from nixpkgs --- buildbot_nix/buildbot_nix.py | 8 +------- nix/worker.nix | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/buildbot_nix/buildbot_nix.py b/buildbot_nix/buildbot_nix.py index 1afdde0..9fa56ae 100644 --- a/buildbot_nix/buildbot_nix.py +++ b/buildbot_nix/buildbot_nix.py @@ -433,13 +433,7 @@ def nix_eval_config( name="evaluate flake", supported_systems=supported_systems, command=[ - "nix", - "run", - "--option", - "accept-flake-config", - "true", - "github:nix-community/nix-eval-jobs", - "--", + "nix-eval-jobs", "--workers", multiprocessing.cpu_count(), "--max-memory-size", diff --git a/nix/worker.nix b/nix/worker.nix index 57b7e6e..8f968f0 100644 --- a/nix/worker.nix +++ b/nix/worker.nix @@ -53,6 +53,7 @@ in pkgs.openssh pkgs.gh pkgs.nix + pkgs.nix-eval-jobs ]; environment.PYTHONPATH = "${python.withPackages (_: [cfg.package])}/${python.sitePackages}"; environment.MASTER_URL = ''tcp:host=localhost:port=9989''; From 14556fd91f037ec4a676b00e873ddd572dc16ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sun, 15 Oct 2023 11:26:46 +0200 Subject: [PATCH 5/5] disable periodic flake updates for now --- buildbot_nix/buildbot_nix.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/buildbot_nix/buildbot_nix.py b/buildbot_nix/buildbot_nix.py index 9fa56ae..7a44dea 100644 --- a/buildbot_nix/buildbot_nix.py +++ b/buildbot_nix/buildbot_nix.py @@ -574,10 +574,10 @@ def config_for_project( nix_supported_systems: list[str], nix_eval_max_memory_size: int, ) -> Project: - # get a deterministic jitter for the project - random.seed(project.name) - # don't run all projects at the same time - jitter = random.randint(1, 60) * 60 + ## get a deterministic jitter for the project + #random.seed(project.name) + ## don't run all projects at the same time + #jitter = random.randint(1, 60) * 60 config["projects"].append(Project(project.name)) config["schedulers"].extend( @@ -624,11 +624,11 @@ def config_for_project( buttonName="Update flakes", ), # updates flakes once a week - schedulers.Periodic( - name=f"{project.id}-update-flake-weekly", - builderNames=[f"{project.name}/update-flake"], - periodicBuildTimer=24 * 60 * 60 * 7 + jitter, - ), + #schedulers.Periodic( + # name=f"{project.id}-update-flake-weekly", + # builderNames=[f"{project.name}/update-flake"], + # periodicBuildTimer=24 * 60 * 60 * 7 + jitter, + #), ] ) has_cachix_auth_token = os.path.isfile(