Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions master-private.cfg-sample
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ flask
libvirt-python
pylint
python-dotenv
pyzabbix
sqlalchemy==1.3.23
treq
setuptools<=80.10.2
88 changes: 1 addition & 87 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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()
Expand Down