From cd95856b3b45749cf054d1d5c8734b6c2259fb8e Mon Sep 17 00:00:00 2001 From: Razvan-Liviu Varzaru Date: Wed, 22 Jul 2026 13:07:47 +0300 Subject: [PATCH] MDBF-1174: Remove Zabbix checks Zabbix has a `BB Accept Builds` metric which was used only for scheduling s390x builds. Due to resource constraints the s390x workers accept one build at a time -> see `worker_locks.yaml` -> using the zabbix metric has no additional benefit. Remove the surrounding zabbix code since we're moving to Prometheus. For now I don't see the need of a Prometheus equivalent for the metric because we already have 3 control mechanisms for the workers load: - locks :: used by dockerlatent masters - max_builds :: used by non-latent masters - scheduling based on worker available CPU's count :: used by master-migration --- master-private.cfg-sample | 12 ------ requirements.txt | 1 - utils.py | 88 +-------------------------------------- 3 files changed, 1 insertion(+), 100 deletions(-) diff --git a/master-private.cfg-sample b/master-private.cfg-sample index ada32e9c8..a9a2545d6 100644 --- a/master-private.cfg-sample +++ b/master-private.cfg-sample @@ -5,8 +5,6 @@ private["db_password"] = "password" private["db_mtr_db"] = "buildbot" private["gh_secret"] = "gh_secret" private["minio_url"] = "https://access_key:secret_key@minio.mariadb.org" -private["zabbix_server"] = "https://zabbix.server" -private["zabbix_token"] = "zabbix_token" private["user_pass"]= { "admin":"user_pass", } @@ -107,16 +105,6 @@ private["docker_workers"]= { "aws-bbw1-docker":"tcp://IP_address:port", } -private["worker_name_mapping"] = { - "s390x-bbw1": "ibm-s390x-ubuntu2404-03", - "s390x-bbw2": "ibm-s390x-sles15", - "s390x-bbw3": "ibm-s390x-rhel8", - "s390x-bbw4": "ibm-s390x-ubuntu22.04", - "s390x-bbw5": "ibm-s390x-rhel9", - "s390x-bbw6": "ibm-s390x-ubuntu2404-01", - "s390x-bbw7": "ibm-s390x-ubuntu2404-02", -} - private["gh_mdbci"]= { "username":"username", "name":"username", diff --git a/requirements.txt b/requirements.txt index c29adc123..baded37f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,6 @@ flask libvirt-python pylint python-dotenv -pyzabbix sqlalchemy==1.3.23 treq setuptools<=80.10.2 \ No newline at end of file diff --git a/utils.py b/utils.py index 4735c975f..8df8a2e79 100644 --- a/utils.py +++ b/utils.py @@ -5,7 +5,6 @@ from typing import Any, Generator, Tuple import docker -from pyzabbix import ZabbixAPI from twisted.internet import defer, threads from twisted.python import log @@ -296,38 +295,7 @@ def build_request_sort_key(request: BuildRequest): @defer.inlineCallbacks def canStartBuild( builder: Builder, wfb: AbstractWorkerForBuilder, request: BuildRequest -) -> Generator[defer.Deferred, None, bool]: - worker: AbstractWorker = wfb.worker - if "s390x" not in worker.name: - return True - - worker_prefix = "-".join(worker.name.split("-")[0:2]) - worker_name = private_config["private"]["worker_name_mapping"][worker_prefix] - - try: - load = yield threads.deferToThread( - getMetric, worker_name, "BB_accept_new_build" - ) - except (ZabbixNoHostFound, ZabbixToManyItems, ZabbixNoItemFound) as e: - log.err(e, f"Zabbix Error: Check configuration for {worker_name}") - return True # This is clearly a Zabbix misconfiguration, let the build start - except ZabbixTooOldData as e: - log.err(e, f"Zabbix Error: Too old Zabbix data for worker {worker_name}") - return False - except Exception as e: - log.err( - e, f"Zabbix Error: Unexpected error when fetching data for {worker_name}" - ) - return True # In case of other errors, e.g. network issues, let the build start - - if float(load) > 60: - worker.quarantine_timeout = 60 - worker.putInQuarantine() - return False - - worker.quarantine_timeout = 120 - worker.putInQuarantine() - worker.resetQuarantine() +) -> bool: return True @@ -594,60 +562,6 @@ def prioritizeBuilders( return builders -class ZabbixTooOldData(Exception): - pass - - -class ZabbixToManyItems(Exception): - pass - - -class ZabbixNoItemFound(Exception): - pass - - -class ZabbixNoHostFound(Exception): - pass - - -# Zabbix helper -def getMetric(hostname: str, metric: str) -> Any: - # set API - zapi = ZabbixAPI(private_config["private"]["zabbix_server"]) - zapi.session.verify = True - zapi.timeout = 3 - - zapi.login(api_token=private_config["private"]["zabbix_token"]) - - host_id = None - for h in zapi.host.get(output="extend"): - if h["host"] == hostname: - host_id = h["hostid"] - break - - if host_id is None: - raise ZabbixNoHostFound - - hostitems = zapi.item.get(filter={"hostid": host_id, "name": metric}) - - if len(hostitems) > 1: - raise ZabbixToManyItems - if len(hostitems) == 0: - raise ZabbixNoItemFound - - hostitem = hostitems[0] - - last_value = hostitem["lastvalue"] - last_time = datetime.fromtimestamp(int(hostitem["lastclock"])) - - elapsed_from_last = (datetime.now() - last_time).total_seconds() - - if elapsed_from_last >= 80: - raise ZabbixTooOldData - - return last_value - - def read_template(template_name: str) -> str: with open(f"/srv/buildbot/master/script_templates/{template_name}.sh") as f: return f.read()