Skip to content

Commit 7acedfb

Browse files
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 surounding 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 two 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
1 parent ab1823a commit 7acedfb

2 files changed

Lines changed: 1 addition & 97 deletions

File tree

master-private.cfg-sample

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,6 @@ private["docker_workers"]= {
107107
"aws-bbw1-docker":"tcp://IP_address:port",
108108
}
109109

110-
private["worker_name_mapping"] = {
111-
"s390x-bbw1": "ibm-s390x-ubuntu2404-03",
112-
"s390x-bbw2": "ibm-s390x-sles15",
113-
"s390x-bbw3": "ibm-s390x-rhel8",
114-
"s390x-bbw4": "ibm-s390x-ubuntu22.04",
115-
"s390x-bbw5": "ibm-s390x-rhel9",
116-
"s390x-bbw6": "ibm-s390x-ubuntu2404-01",
117-
"s390x-bbw7": "ibm-s390x-ubuntu2404-02",
118-
}
119-
120110
private["gh_mdbci"]= {
121111
"username":"username",
122112
"name":"username",

utils.py

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from typing import Any, Generator, Tuple
66

77
import docker
8-
from pyzabbix import ZabbixAPI
98
from twisted.internet import defer, threads
109
from twisted.python import log
1110

@@ -296,38 +295,7 @@ def build_request_sort_key(request: BuildRequest):
296295
@defer.inlineCallbacks
297296
def canStartBuild(
298297
builder: Builder, wfb: AbstractWorkerForBuilder, request: BuildRequest
299-
) -> Generator[defer.Deferred, None, bool]:
300-
worker: AbstractWorker = wfb.worker
301-
if "s390x" not in worker.name:
302-
return True
303-
304-
worker_prefix = "-".join(worker.name.split("-")[0:2])
305-
worker_name = private_config["private"]["worker_name_mapping"][worker_prefix]
306-
307-
try:
308-
load = yield threads.deferToThread(
309-
getMetric, worker_name, "BB_accept_new_build"
310-
)
311-
except (ZabbixNoHostFound, ZabbixToManyItems, ZabbixNoItemFound) as e:
312-
log.err(e, f"Zabbix Error: Check configuration for {worker_name}")
313-
return True # This is clearly a Zabbix misconfiguration, let the build start
314-
except ZabbixTooOldData as e:
315-
log.err(e, f"Zabbix Error: Too old Zabbix data for worker {worker_name}")
316-
return False
317-
except Exception as e:
318-
log.err(
319-
e, f"Zabbix Error: Unexpected error when fetching data for {worker_name}"
320-
)
321-
return True # In case of other errors, e.g. network issues, let the build start
322-
323-
if float(load) > 60:
324-
worker.quarantine_timeout = 60
325-
worker.putInQuarantine()
326-
return False
327-
328-
worker.quarantine_timeout = 120
329-
worker.putInQuarantine()
330-
worker.resetQuarantine()
298+
) -> bool:
331299
return True
332300

333301

@@ -594,60 +562,6 @@ def prioritizeBuilders(
594562
return builders
595563

596564

597-
class ZabbixTooOldData(Exception):
598-
pass
599-
600-
601-
class ZabbixToManyItems(Exception):
602-
pass
603-
604-
605-
class ZabbixNoItemFound(Exception):
606-
pass
607-
608-
609-
class ZabbixNoHostFound(Exception):
610-
pass
611-
612-
613-
# Zabbix helper
614-
def getMetric(hostname: str, metric: str) -> Any:
615-
# set API
616-
zapi = ZabbixAPI(private_config["private"]["zabbix_server"])
617-
zapi.session.verify = True
618-
zapi.timeout = 3
619-
620-
zapi.login(api_token=private_config["private"]["zabbix_token"])
621-
622-
host_id = None
623-
for h in zapi.host.get(output="extend"):
624-
if h["host"] == hostname:
625-
host_id = h["hostid"]
626-
break
627-
628-
if host_id is None:
629-
raise ZabbixNoHostFound
630-
631-
hostitems = zapi.item.get(filter={"hostid": host_id, "name": metric})
632-
633-
if len(hostitems) > 1:
634-
raise ZabbixToManyItems
635-
if len(hostitems) == 0:
636-
raise ZabbixNoItemFound
637-
638-
hostitem = hostitems[0]
639-
640-
last_value = hostitem["lastvalue"]
641-
last_time = datetime.fromtimestamp(int(hostitem["lastclock"]))
642-
643-
elapsed_from_last = (datetime.now() - last_time).total_seconds()
644-
645-
if elapsed_from_last >= 80:
646-
raise ZabbixTooOldData
647-
648-
return last_value
649-
650-
651565
def read_template(template_name: str) -> str:
652566
with open(f"/srv/buildbot/master/script_templates/{template_name}.sh") as f:
653567
return f.read()

0 commit comments

Comments
 (0)