[buildbot] phase1: refactor worker parsing

LEDE Commits lede-commits at lists.infradead.org
Mon May 15 08:39:45 PDT 2023


ynezz pushed a commit to buildbot.git, branch master:
https://git.openwrt.org/344059d3bc43555559bfd3bffd928e00a79c006b

commit 344059d3bc43555559bfd3bffd928e00a79c006b
Author: Thibaut VARÈNE <hacks at slashdirt.org>
AuthorDate: Thu Oct 27 14:32:30 2022 +0200

    phase1: refactor worker parsing
    
    Signed-off-by: Thibaut VARÈNE <hacks at slashdirt.org>
---
 phase1/master.cfg | 46 ++++++++++++++++++++++++++++------------------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/phase1/master.cfg b/phase1/master.cfg
index fdbb2cd..53d2098 100644
--- a/phase1/master.cfg
+++ b/phase1/master.cfg
@@ -131,27 +131,39 @@ c['buildbotURL'] = inip1.get("buildbot_url")
 c['workers'] = []
 NetLocks = dict()
 
+def ini_parse_workers(section):
+	name = section.get("name")
+	password = section.get("password")
+	phase = section.getint("phase")
+
+	if not name or not password or not phase == 1:
+		log.msg("invalid worker configuration ignored: {}".format(repr(section)))
+		return
+
+	sl_props = { 'dl_lock':None, 'ul_lock':None }
+	if "dl_lock" in section:
+		lockname = section.get("dl_lock")
+		sl_props['dl_lock'] = lockname
+		if lockname not in NetLocks:
+			NetLocks[lockname] = locks.MasterLock(lockname)
+	if "ul_lock" in section:
+		lockname = section.get("ul_lock")
+		sl_props['ul_lock'] = lockname
+		if lockname not in NetLocks:
+			NetLocks[lockname] = locks.MasterLock(lockname)
+
+	log.msg("Configured worker: {}".format(name))
+	c['workers'].append(Worker(name, password, max_builds = 1, properties = sl_props))
+
+
 for section in ini.sections():
 	if section.startswith("branch "):
 		ini_parse_branch(ini[section])
 
 	if section.startswith("worker "):
-		if ini.has_option(section, "name") and ini.has_option(section, "password") and \
-		   (not ini.has_option(section, "phase") or ini.getint(section, "phase") == 1):
-			sl_props = { 'dl_lock':None, 'ul_lock':None }
-			name = ini.get(section, "name")
-			password = ini.get(section, "password")
-			if ini.has_option(section, "dl_lock"):
-				lockname = ini.get(section, "dl_lock")
-				sl_props['dl_lock'] = lockname
-				if lockname not in NetLocks:
-					NetLocks[lockname] = locks.MasterLock(lockname)
-			if ini.has_option(section, "ul_lock"):
-				lockname = ini.get(section, "ul_lock")
-				sl_props['ul_lock'] = lockname
-				if lockname not in NetLocks:
-					NetLocks[lockname] = locks.MasterLock(lockname)
-			c['workers'].append(Worker(name, password, max_builds = 1, properties = sl_props))
+		ini_parse_workers(ini[section])
+
+branchNames = [branches[b]["name"] for b in branches]
 
 c['protocols'] = {'pb': {'port': pb_port}}
 
@@ -255,8 +267,6 @@ c['prioritizeBuilders'] = prioritizeBuilders
 
 ####### CHANGESOURCES
 
-branchNames = [branches[b]["name"] for b in branches]
-
 # find targets
 targets = set()
 




More information about the lede-commits mailing list