1- from twisted . internet import defer
1+ import os
22
3- from buildbot .plugins import *
4- from buildbot .process .properties import Properties , Property
5- from buildbot .process .remotecommand import RemoteCommand
6- from buildbot .steps .mtrlogobserver import MTR , MtrLogObserver
7- from buildbot .steps .shell import Compile , SetPropertyFromCommand , ShellCommand , Test
8- from buildbot .steps .source .github import GitHub
9- from constants import *
3+ import yaml
104
11- ####### LOCKS
12- # main_master_lock = util.MasterLock('main_master_lock', maxCount=30)
5+ from buildbot .plugins import util
136
14- hz_bbw1_lock = util .MasterLock ("hz_bbw1_lock" , maxCount = 9 )
15- hz_bbw2_lock = util .MasterLock ("hz_bbw2_lock" , maxCount = 1 )
16- hz_bbw4_lock = util .MasterLock ("hz_bbw4_lock" , maxCount = 9 )
17- hz_bbw5_lock = util .MasterLock ("hz_bbw5_lock" , maxCount = 9 )
18- amd_bbw1_lock = util .MasterLock ("amd_bbw1_lock" , maxCount = 4 )
19- amd_bbw2_lock = util .MasterLock ("amd_bbw2_lock" , maxCount = 6 )
20- intel_bbw1_lock = util .MasterLock ("intel_bbw1_lock" , maxCount = 5 )
21- p9_rhel8_bbw1_lock = util .MasterLock ("p9_rhel8_bbw1_lock" , maxCount = 6 )
22- p9_db_bbw1_lock = util .MasterLock ("p9_db_bbw1_lock" , maxCount = 8 )
23- p9_raptor_bbw1_lock = util .MasterLock ("p9_raptor_bbw1_lock" , maxCount = 6 )
24- aarch_bbw1_lock = util .MasterLock ("aarch64_bbw1_lock" , maxCount = 2 )
25- aarch_bbw2_lock = util .MasterLock ("aarch64_bbw2_lock" , maxCount = 2 )
26- aarch_bbw3_lock = util .MasterLock ("aarch64_bbw3_lock" , maxCount = 2 )
27- aarch_bbw4_lock = util .MasterLock ("aarch64_bbw4_lock" , maxCount = 2 )
28- aarch_bbw5_lock = util .MasterLock ("aarch64_bbw5_lock" , maxCount = 15 )
29- aarch_bbw6_lock = util .MasterLock ("aarch64_bbw6_lock" , maxCount = 15 )
30- aarch_bbw7_lock = util .MasterLock ("aarch64_bbw7_lock" , maxCount = 15 )
31- apexis_bbw1_lock = util .MasterLock ("apexis_bbw1_lock" , maxCount = 1 )
32- apexis_bbw2_lock = util .MasterLock ("apexis_bbw2_lock" , maxCount = 1 )
33- apexis_bbw3_lock = util .MasterLock ("apexis_bbw3_lock" , maxCount = 6 )
34- bg_bbw1_lock = util .MasterLock ("bg_bbw1_lock" , maxCount = 3 )
35- bg_bbw2_lock = util .MasterLock ("bg_bbw2_lock" , maxCount = 2 )
36- bg_bbw3_lock = util .MasterLock ("bg_bbw3_lock" , maxCount = 2 )
37- bg_bbw4_lock = util .MasterLock ("bg_bbw4_lock" , maxCount = 2 )
38- win_bbw1_lock = util .MasterLock ("win_bbw1_lock" , maxCount = 1 )
39- win_bbw2_lock = util .MasterLock ("win_bbw2_lock" , maxCount = 4 )
40- s390x_bbw1_lock = util .MasterLock ("s390x_bbw1_lock" , maxCount = 3 )
41- s390x_bbw2_lock = util .MasterLock ("s390x_bbw2_lock" , maxCount = 3 )
42- s390x_bbw3_lock = util .MasterLock ("s390x_bbw3_lock" , maxCount = 3 )
43- s390x_bbw4_lock = util .MasterLock ("s390x_bbw4_lock" , maxCount = 3 )
44- s390x_bbw5_lock = util .MasterLock ("s390x_bbw5_lock" , maxCount = 3 )
7+ # Local
8+ from constants import builders_install , builders_upgrade , github_status_builders
9+
10+ LOCKS : dict [str , util .MasterLock ] = {}
11+ # worker_locks.yaml currently is in the same folder as locks.py.
12+ # TODO: re-evaluate if this is the right place after multi-master
13+ # is refactored to use a single base master.cfg.
14+ with open (
15+ os .path .join (os .path .dirname (os .path .realpath (__file__ )), "worker_locks.yaml" ),
16+ encoding = "utf-8" ,
17+ ) as file :
18+ locks = yaml .safe_load (file )
19+ for worker_name in locks :
20+ LOCKS [worker_name ] = util .MasterLock (
21+ f"{ worker_name } _lock" , maxCount = locks [worker_name ]
22+ )
4523
4624
4725@util .renderer
@@ -57,71 +35,7 @@ def getLocks(props):
5735 or builder_name in builders_upgrade
5836 ):
5937 return []
60- locks = []
61- # else:
62- # locks = [main_master_lock.access('counting')]
63-
64- if "hz-bbw1-docker" in worker_name :
65- locks = locks + [hz_bbw1_lock .access ("counting" )]
66- if "hz-bbw2-docker" in worker_name :
67- locks = locks + [hz_bbw2_lock .access ("counting" )]
68- if "hz-bbw4-docker" in worker_name :
69- locks = locks + [hz_bbw4_lock .access ("counting" )]
70- if "hz-bbw5-docker" in worker_name :
71- locks = locks + [hz_bbw5_lock .access ("counting" )]
72- if "intel-bbw1-docker" in worker_name :
73- locks = locks + [intel_bbw1_lock .access ("counting" )]
74- if "ppc64le-rhel8-bbw1-docker" in worker_name :
75- locks = locks + [p9_rhel8_bbw1_lock .access ("counting" )]
76- if "ppc64le-db-bbw1-docker" in worker_name :
77- locks = locks + [p9_db_bbw1_lock .access ("counting" )]
78- if "ppc64le-raptor-bbw1-docker" in worker_name :
79- locks = locks + [p9_raptor_bbw1_lock .access ("counting" )]
80- if "aarch64-bbw1-docker" in worker_name :
81- locks = locks + [aarch_bbw1_lock .access ("counting" )]
82- if "aarch64-bbw2-docker" in worker_name :
83- locks = locks + [aarch_bbw2_lock .access ("counting" )]
84- if "aarch64-bbw3-docker" in worker_name :
85- locks = locks + [aarch_bbw3_lock .access ("counting" )]
86- if "aarch64-bbw4-docker" in worker_name :
87- locks = locks + [aarch_bbw4_lock .access ("counting" )]
88- if "aarch64-bbw5-docker" in worker_name :
89- locks = locks + [aarch_bbw5_lock .access ("counting" )]
90- if "aarch64-bbw6-docker" in worker_name :
91- locks = locks + [aarch_bbw6_lock .access ("counting" )]
92- if "aarch64-bbw7-docker" in worker_name :
93- locks = locks + [aarch_bbw7_lock .access ("counting" )]
94- if "fjord1-docker" in worker_name :
95- locks = locks + [apexis_bbw1_lock .access ("counting" )]
96- if "fjord2-docker" in worker_name :
97- locks = locks + [apexis_bbw2_lock .access ("counting" )]
98- if "ns-x64-bbw1-docker" in worker_name :
99- locks = locks + [bg_bbw1_lock .access ("counting" )]
100- if "ns-x64-bbw2-docker" in worker_name :
101- locks = locks + [bg_bbw2_lock .access ("counting" )]
102- if "ns-x64-bbw3-docker" in worker_name :
103- locks = locks + [bg_bbw3_lock .access ("counting" )]
104- if "ns-x64-bbw4-docker" in worker_name :
105- locks = locks + [bg_bbw4_lock .access ("counting" )]
106- if "bbw1-docker-windows" in worker_name :
107- locks = locks + [win_bbw1_lock .access ("counting" )]
108- if "bbw2-docker-windows" in worker_name :
109- locks = locks + [win_bbw2_lock .access ("counting" )]
110- if "s390x-bbw1-docker" in worker_name :
111- locks = locks + [s390x_bbw1_lock .access ("counting" )]
112- if "s390x-bbw2-docker" in worker_name :
113- locks = locks + [s390x_bbw2_lock .access ("counting" )]
114- if "s390x-bbw3-docker" in worker_name :
115- locks = locks + [s390x_bbw3_lock .access ("counting" )]
116- if "s390x-bbw4-docker" in worker_name :
117- locks = locks + [s390x_bbw4_lock .access ("counting" )]
118- if "s390x-bbw5-docker" in worker_name :
119- locks = locks + [s390x_bbw5_lock .access ("counting" )]
120- if "amd-bbw1-docker" in worker_name :
121- locks = locks + [amd_bbw1_lock .access ("counting" )]
122- if "amd-bbw2-docker" in worker_name :
123- locks = locks + [amd_bbw2_lock .access ("counting" )]
124- if "apexis-bbw3-docker" in worker_name :
125- locks = locks + [apexis_bbw3_lock .access ("counting" )]
12638
127- return locks
39+ if worker_name not in LOCKS :
40+ return []
41+ return [LOCKS [worker_name ].access ("counting" )]
0 commit comments