Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: masters/master.chromiumos/master.cfg

Issue 2250443002: Update floating builder logic, add to "chromiumos" (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Pylint fixes. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | masters/master.chromiumos/slave_pool.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # -*- python -*- 1 # -*- python -*-
2 # ex: set syntax=python: 2 # ex: set syntax=python:
3 3
4 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 4 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
5 # Use of this source code is governed by a BSD-style license that can be 5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file. 6 # found in the LICENSE file.
7 7
8 # This is the buildmaster config file for the 'chromeos' bot. It must 8 # This is the buildmaster config file for the 'chromeos' bot. It must
9 # be installed as 'master.cfg' in your buildmaster's base directory 9 # be installed as 'master.cfg' in your buildmaster's base directory
10 # (although the filename can be changed with the --basedir option to 10 # (although the filename can be changed with the --basedir option to
11 # 'mktap buildbot master'). 11 # 'mktap buildbot master').
12 12
13 # It has one job: define a dictionary named BuildmasterConfig. This 13 # It has one job: define a dictionary named BuildmasterConfig. This
14 # dictionary has a variety of keys to control different aspects of the 14 # dictionary has a variety of keys to control different aspects of the
15 # buildmaster. They are documented in docs/config.xhtml . 15 # buildmaster. They are documented in docs/config.xhtml .
16 16
17 import datetime
17 import json 18 import json
18 import os 19 import os
19 import re 20 import re
20 21
21 from buildbot.changes.filter import ChangeFilter 22 from buildbot.changes.filter import ChangeFilter
22 from buildbot.changes.pb import PBChangeSource 23 from buildbot.changes.pb import PBChangeSource
23 from buildbot.scheduler import Periodic 24 from buildbot.scheduler import Periodic
24 from twisted.python import log 25 from twisted.python import log
25 26
26 # These modules come from scripts/master, which must be in the PYTHONPATH. 27 # These modules come from scripts/master, which must be in the PYTHONPATH.
28 from master import floating_builder
27 from master import master_utils 29 from master import master_utils
28 from master import slaves_list 30 from master import slaves_list
29 from master.chromeos_manifest_scheduler import \ 31 from master.chromeos_manifest_scheduler import \
30 ChromeOSManifestSingleBranchScheduler, ChromeOSManifestAnyBranchScheduler, \ 32 ChromeOSManifestSingleBranchScheduler, ChromeOSManifestAnyBranchScheduler, \
31 FilterNewSpec, CommentRespectingGitPoller 33 FilterNewSpec, CommentRespectingGitPoller
32 from master.cros import builder_config 34 from master.cros import builder_config
33 from master.factory import annotator_factory, chromeos_factory 35 from master.factory import annotator_factory, chromeos_factory
34 36
35 # These modules come from scripts/common, which must be in the PYTHONPATH. 37 # These modules come from scripts/common, which must be in the PYTHONPATH.
36 import chromiumos_board_config 38 import chromiumos_board_config as board_config
37 import config 39 import config
38 import master_site_config 40 import master_site_config
39 from master.cros import builder_config 41 from master.cros import builder_config
42 from common import slave_alloc
40 from common.cros_chromite import ChromiteTarget 43 from common.cros_chromite import ChromiteTarget
41 44
42 ActiveMaster = master_site_config.ChromiumOS 45 ActiveMaster = master_site_config.ChromiumOS
43 DRY_RUN = not ActiveMaster.is_production_host 46 DRY_RUN = not ActiveMaster.is_production_host
44 47
45 # This is the dictionary that the buildmaster pays attention to. We also use 48 # This is the dictionary that the buildmaster pays attention to. We also use
46 # a shorter alias to save typing. 49 # a shorter alias to save typing.
47 c = BuildmasterConfig = {} 50 c = BuildmasterConfig = {}
48 51
49 config.DatabaseSetup(c) 52 config.DatabaseSetup(c)
(...skipping 11 matching lines...) Expand all
61 # name (required): the name used to describe this bilder 64 # name (required): the name used to describe this bilder
62 # slavename (required): which slave to use, must appear in c['slaves'] 65 # slavename (required): which slave to use, must appear in c['slaves']
63 # builddir (required): which subdirectory to run the builder in 66 # builddir (required): which subdirectory to run the builder in
64 # factory (required): a BuildFactory to define how the build is run 67 # factory (required): a BuildFactory to define how the build is run
65 # category (optional): it is not used in the normal 'buildbot' meaning. It is 68 # category (optional): it is not used in the normal 'buildbot' meaning. It is
66 # used by JS generation to determine which steps it should 69 # used by JS generation to determine which steps it should
67 # look for to close the tree. 70 # look for to close the tree.
68 # 71 #
69 72
70 # General source to add in cbuildbot types: 73 # General source to add in cbuildbot types:
71 def GenCBuild(cfg): 74 def GenCBuild(bc):
72 """Generate a cbuild buildbot configuration 75 """Generate a cbuild buildbot configuration
73 76
74 Create a buildbot builder configuration and return a builder 77 Create a buildbot builder configuration and return a builder
75 dictionary associated with it. 78 dictionary associated with it.
76 79
77 Arguments: 80 Arguments:
78 cfg: (builder_config.BuilderConfig) The config. 81 bc: (builder_config.BuilderConfig) The config.
79 root_dir: Root of the directory where all work will take place. 82 root_dir: Root of the directory where all work will take place.
80 name: Name as displayed in the waterfall, if None generate automatically. 83 name: Name as displayed in the waterfall, if None generate automatically.
81 branch: The branch to set the builder up for, defaults to 'master' 84 branch: The branch to set the builder up for, defaults to 'master'
82 Returns: 85 Returns:
83 A builder dictionary assocaited with a factory 86 A builder dictionary assocaited with a factory
84 """ 87 """
85 categories = ['1release full'] 88 categories = ['1release full']
86 if cfg.closer: 89 if bc.closer:
87 categories.append('closer') 90 categories.append('closer')
88 else: 91 else:
89 categories.append('info') 92 categories.append('info')
90 93
91 # Give the SDK builder more time. 94 # Give the SDK builder more time.
92 factory_kwargs = {} 95 factory_kwargs = {}
93 if cfg.timeout: 96 if bc.timeout:
94 factory_kwargs['max_time'] = cfg.timeout 97 factory_kwargs['max_time'] = bc.timeout
95 98
96 properties = { 99 properties = {
97 'cbb_config': cfg.config.name, 100 'cbb_config': bc.config.name,
98 } 101 }
99 if cfg.cbb_variant: 102 if bc.cbb_variant:
100 properties['cbb_variant'] = cfg.cbb_variant 103 properties['cbb_variant'] = bc.cbb_variant
101 builder = { 104 builder = {
102 'name': str(cfg.builder_name), 105 'name': str(bc.builder_name),
103 'builddir': '%s-master' % (cfg.config.name,), 106 'builddir': '%s-master' % (bc.config.name,),
104 'category': '|'.join(categories), 107 'category': '|'.join(categories),
105 'auto_reboot': cfg.auto_reboot, 108 'auto_reboot': bc.auto_reboot,
106 'factory': chromeos_factory.ChromiteRecipeFactory( 109 'factory': chromeos_factory.ChromiteRecipeFactory(
107 factory_obj, 'cros/cbuildbot', **factory_kwargs), 110 factory_obj, 'cros/cbuildbot', **factory_kwargs),
108 'properties': properties, 111 'properties': properties,
109 } 112 }
110 113
111 if cfg.collapse: 114 if bc.collapse:
112 builder['mergeRequests'] = builder_config.AlwaysCollapseFunc 115 builder['mergeRequests'] = builder_config.AlwaysCollapseFunc
113 return builder 116 return builder
114 117
115 # Associate the slaves to the builders. 118 # Associate the slaves to the builders.
116 c['builders'] = [] 119 c['builders'] = []
117 120
118 for cfg in chromiumos_board_config.builder_configs.itervalues(): 121 for cfg in board_config.builder_configs.itervalues():
119 c['builders'].append(GenCBuild(cfg)) 122 c['builders'].append(GenCBuild(cfg))
120 123
121 124
122 ####### CHANGESOURCES 125 ####### CHANGESOURCES
123 126
124 MANIFEST_VERSIONS_REPO = ( 127 MANIFEST_VERSIONS_REPO = (
125 'https://chromium.googlesource.com/chromiumos/manifest-versions') 128 'https://chromium.googlesource.com/chromiumos/manifest-versions')
126 c['change_source'] = [PBChangeSource()] 129 c['change_source'] = [PBChangeSource()]
127 c['change_source'].append(CommentRespectingGitPoller( 130 c['change_source'].append(CommentRespectingGitPoller(
128 repourl=MANIFEST_VERSIONS_REPO, 131 repourl=MANIFEST_VERSIONS_REPO,
129 branch='master', 132 branch='master',
130 workdir='/tmp/chromiumos-manifest-versions', 133 workdir='/tmp/chromiumos-manifest-versions',
131 pollinterval=10)) 134 pollinterval=10))
132 135
133 136
134 ####### SCHEDULERS 137 ####### SCHEDULERS
135 138
136 def GetBuilders(func): 139 def GetBuilders(func):
137 return [b for b in chromiumos_board_config.builder_configs.itervalues() 140 return [b for b in board_config.builder_configs.itervalues()
138 if func(b)] 141 if func(b)]
139 142
140 143
141 def GetBuilderNames(func): 144 def GetBuilderNames(func):
142 return [str(builder_config.builder_name) 145 return [str(builder_config.builder_name)
143 for builder_config in GetBuilders(func)] 146 for builder_config in GetBuilders(func)]
144 147
145 148
146 def GetBuilderNamesForCategory(category): 149 def GetBuilderNamesForCategory(category):
147 return GetBuilderNames(lambda b: b.config.category == category) 150 return GetBuilderNames(lambda b: b.config.category == category)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 GetBuilderNamesForCategory(ChromiteTarget.SDK) 187 GetBuilderNamesForCategory(ChromiteTarget.SDK)
185 ), 188 ),
186 ) 189 )
187 190
188 c['schedulers'] = [ 191 c['schedulers'] = [
189 s_paladin, s_pfq, s_chromeos_default, s_refresh_packages, 192 s_paladin, s_pfq, s_chromeos_default, s_refresh_packages,
190 ] 193 ]
191 194
192 ####### BUILDSLAVES 195 ####### BUILDSLAVES
193 196
197 # Returns 'True' if a builder is experimental.
198 def cros_builder_experimental(name):
199 config = board_config.builder_name_map.get(name)
200 return config and config.is_experimental
201
194 # the 'slaves' list defines the set of allowable buildslaves. Each element is a 202 # the 'slaves' list defines the set of allowable buildslaves. Each element is a
195 # tuple of bot-name and bot-password. These correspond to values given to the 203 # tuple of bot-name and bot-password. These correspond to values given to the
196 # buildslave's mktap invocation. 204 # buildslave's mktap invocation.
197 205
198 # First, load the list from slaves.cfg. 206 # First, load the list from slaves.cfg.
199 slaves = slaves_list.SlavesList('slaves.cfg', 'ChromiumOS') 207 slaves = slaves_list.SlavesList('slaves.cfg', 'ChromiumOS')
200 if not slaves.GetSlaves(): 208 slave_map = board_config.slave_allocator.GetSlaveMap()
201 raise ValueError("Failed to load slaves.") 209
202 for builder in c['builders']: 210 # Assert our slave integrity and build our floating slave list.
203 builder['slavenames'] = slaves.GetSlavesName(builder=builder['name']) 211 #
212 # We will loop through every builder, identify the primary and floating slaves
213 # for that builder, and set its 'nextSlave' function to our floating builder.
214 slave_class_map = slave_alloc.BuildClassMap(slave_map)
215 for b in c['builders']:
216 builder_name = b['name']
217 b['slavenames'] = slaves.GetSlavesName(builder=builder_name)
218 assert b['slavenames'], 'No slaves allocated for [%s]' % (builder_name,)
219
220 bc = board_config.builder_configs[builder_name]
221 if bc.floating and not cros_builder_experimental(builder_name):
222 fs = floating_builder.FloatingSet()
223
224 for slave in b['slavenames']:
225 if slave in slave_class_map.get('floating', {}).get(bc.config.category, () ):
226 fs.AddFloating(slave)
227 else:
228 fs.AddPrimary(slave)
229 b['nextSlave'] = fs.NextSlaveFunc(datetime.timedelta(minutes=15))
230
231 # Enable verbose logging.
232 # TODO(dnj): Disable when reliable.
233 b['nextSlave'].verbose = True
234 log.msg('Assigning builder [%s] to `nextSlave` function: %s' % (
235 builder_name, b['nextSlave']))
204 236
205 # The 'slaves' list defines the set of allowable buildslaves. List all the 237 # The 'slaves' list defines the set of allowable buildslaves. List all the
206 # slaves registered to a builder. Remove dupes. 238 # slaves registered to a builder. Remove dupes.
207 c['slaves'] = master_utils.AutoSetupSlaves(c['builders'], 239 c['slaves'] = master_utils.AutoSetupSlaves(c['builders'],
208 config.Master.GetBotPassword()) 240 config.Master.GetBotPassword())
209 241
210 242
211 ####### STATUS TARGETS 243 ####### STATUS TARGETS
212 244
213 # Buildbot master url: 245 # Buildbot master url:
214 # Must come before AutoSetupMaster(). 246 # Must come before AutoSetupMaster().
215 c['buildbotURL'] = ActiveMaster.buildbot_url 247 c['buildbotURL'] = ActiveMaster.buildbot_url
216 248
217 # Returns 'True' if a builder is experimental.
218 def cros_builder_experimental(name):
219 config = chromiumos_board_config.builder_name_map.get(name)
220 return config and config.is_experimental
221
222 # Adds common status and tools to this master. 249 # Adds common status and tools to this master.
223 def cros_builder_doc(name): 250 def cros_builder_doc(name):
224 config = chromiumos_board_config.builder_name_map.get(name) 251 config = board_config.builder_name_map.get(name)
225 if config: 252 if config:
226 doc = config.config.get('doc') 253 doc = config.config.get('doc')
227 if doc: 254 if doc:
228 return {'url': doc} 255 return {'url': doc}
229 return None 256 return None
230 257
231 web_template_globals = { 258 web_template_globals = {
232 'cros_builder_experimental': cros_builder_experimental, 259 'cros_builder_experimental': cros_builder_experimental,
233 'cros_builder_doc': cros_builder_doc, 260 'cros_builder_doc': cros_builder_doc,
234 } 261 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 categories_steps = { 297 categories_steps = {
271 'closer': [ 298 'closer': [
272 'update_scripts', 299 'update_scripts',
273 'Clear and Clone chromite', 300 'Clear and Clone chromite',
274 ] 301 ]
275 } 302 }
276 303
277 if not ActiveMaster.is_production_host: 304 if not ActiveMaster.is_production_host:
278 # Save our slave pool state. This is populated when our 'slaves' variable 305 # Save our slave pool state. This is populated when our 'slaves' variable
279 # gets generated. 306 # gets generated.
280 chromiumos_board_config.slave_allocator.SaveState() 307 board_config.slave_allocator.SaveState()
281 slave_map = chromiumos_board_config.slave_allocator.GetSlaveMap()
282 if slave_map.unallocated: 308 if slave_map.unallocated:
283 log.msg("The following slaves were not allocated: %s" % ( 309 log.msg("The following slaves were not allocated: %s" % (
284 sorted(slave_map.unallocated),)) 310 sorted(slave_map.unallocated),))
285 311
286 # Disable 'auto_reboot' on slaves for local testing. 312 # Disable 'auto_reboot' on slaves for local testing.
287 for builder in c['builders']: 313 for builder in c['builders']:
288 builder['auto_reboot'] = False 314 builder['auto_reboot'] = False
OLDNEW
« no previous file with comments | « no previous file | masters/master.chromiumos/slave_pool.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698