OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import ast | 5 import ast |
6 import os | 6 import os |
7 | 7 |
8 from buildbot.schedulers.basic import SingleBranchScheduler | 8 from buildbot.schedulers.basic import SingleBranchScheduler |
9 from buildbot.status.mail import MailNotifier | 9 from buildbot.status.mail import MailNotifier |
10 | 10 |
11 from config_bootstrap import Master | 11 from config_bootstrap import Master |
12 | 12 |
13 from common import chromium_utils | 13 from common import chromium_utils |
14 | 14 |
15 from master import gitiles_poller | 15 from master import gitiles_poller |
16 from master import master_utils | 16 from master import master_utils |
17 from master import slaves_list | 17 from master import slaves_list |
18 from master.factory import annotator_factory | 18 from master.factory import annotator_factory |
19 | 19 |
20 | 20 |
21 def PopulateBuildmasterConfig(BuildmasterConfig, builders_path, | 21 def PopulateBuildmasterConfig(BuildmasterConfig, builders_path, |
22 master_cls=None): | 22 active_master_cls): |
23 """Read builders_path and populate a build master config dict.""" | 23 """Read builders_path and populate a build master config dict.""" |
24 master_cls = master_cls or Master | |
25 builders = chromium_utils.ReadBuildersFile(builders_path) | 24 builders = chromium_utils.ReadBuildersFile(builders_path) |
26 _Populate(BuildmasterConfig, builders, master_cls) | 25 _Populate(BuildmasterConfig, builders, active_master_cls) |
27 | 26 |
28 | 27 |
29 | 28 def _Populate(BuildmasterConfig, builders, active_master_cls): |
30 def _Populate(BuildmasterConfig, builders, master_cls): | 29 m_annotator = annotator_factory.AnnotatorFactory(active_master_cls) |
31 classname = builders['master_classname'] | |
32 base_class = getattr(master_cls, builders['master_base_class']) | |
33 active_master_cls = type(classname, (base_class,), { | |
34 'buildbot_url': builders['buildbot_url'], | |
35 'project_name': builders['master_classname'], | |
36 'master_port': int(builders['master_port']), | |
37 'master_port_alt': int(builders['master_port_alt']), | |
38 'slave_port': int(builders['slave_port']), | |
39 }) | |
40 | |
41 # TODO: Modify this and the factory call, below, so that we can pass the | |
42 # path to the builders.pyl file through the annotator to the slave so that | |
43 # the slave can get the recipe name and the factory properties dynamically | |
44 # without needing the master to re-read things. | |
45 m_annotator = annotator_factory.AnnotatorFactory() | |
46 | 30 |
47 c = BuildmasterConfig | 31 c = BuildmasterConfig |
48 c['logCompressionLimit'] = False | 32 c['logCompressionLimit'] = False |
49 c['projectName'] = active_master_cls.project_name | 33 c['projectName'] = active_master_cls.project_name |
50 c['projectURL'] = master_cls.project_url | 34 c['projectURL'] = Master.project_url |
51 c['buildbotURL'] = active_master_cls.buildbot_url | 35 c['buildbotURL'] = active_master_cls.buildbot_url |
52 | 36 |
53 # This sets c['db_url'] to the database connect string in found in | 37 # This sets c['db_url'] to the database connect string in found in |
54 # the .dbconfig in the master directory, if it exists. If this is | 38 # the .dbconfig in the master directory, if it exists. If this is |
55 # a production host, it must exist. | 39 # a production host, it must exist. |
56 chromium_utils.DatabaseSetup( | 40 chromium_utils.DatabaseSetup( |
57 c, | 41 c, |
58 require_dbconfig=active_master_cls.is_production_host) | 42 require_dbconfig=active_master_cls.is_production_host) |
59 | 43 |
60 if builders['master_type'] == 'waterfall': | 44 if builders['master_type'] == 'waterfall': |
(...skipping 20 matching lines...) Expand all Loading... |
81 SingleBranchScheduler(name='source', | 65 SingleBranchScheduler(name='source', |
82 branch='master', | 66 branch='master', |
83 treeStableTimer=60, | 67 treeStableTimer=60, |
84 builderNames=[b['name'] for b in c['builders']]) | 68 builderNames=[b['name'] for b in c['builders']]) |
85 ] | 69 ] |
86 | 70 |
87 # The 'slaves' list defines the set of allowable buildslaves. List all the | 71 # The 'slaves' list defines the set of allowable buildslaves. List all the |
88 # slaves registered to a builder. Remove dupes. | 72 # slaves registered to a builder. Remove dupes. |
89 c['slaves'] = master_utils.AutoSetupSlaves( | 73 c['slaves'] = master_utils.AutoSetupSlaves( |
90 c['builders'], | 74 c['builders'], |
91 master_cls.GetBotPassword(), | 75 Master.GetBotPassword(), |
92 missing_recipients=['buildbot@chromium-build-health.appspotmail.com']) | 76 missing_recipients=['buildbot@chromium-build-health.appspotmail.com']) |
93 | 77 |
94 # This does some sanity checks on the configuration. | 78 # This does some sanity checks on the configuration. |
95 slaves = slaves_list.BaseSlavesList( | 79 slaves = slaves_list.BaseSlavesList( |
96 chromium_utils.GetSlavesFromBuilders(builders), | 80 chromium_utils.GetSlavesFromBuilders(builders), |
97 builders['master_classname']) | 81 builders['master_classname']) |
98 master_utils.VerifySetup(c, slaves) | 82 master_utils.VerifySetup(c, slaves) |
99 | 83 |
100 # Adds common status and tools to this master. | 84 # Adds common status and tools to this master. |
101 # TODO: Look at the logic in this routine to see if any of the logic | 85 # TODO: Look at the logic in this routine to see if any of the logic |
102 # in this routine can be moved there to simplify things. | 86 # in this routine can be moved there to simplify things. |
103 master_utils.AutoSetupMaster(c, active_master_cls, | 87 master_utils.AutoSetupMaster(c, active_master_cls, |
104 public_html='../master.chromium/public_html', | 88 public_html='../master.chromium/public_html', |
105 templates=builders['templates'], | 89 templates=builders['templates'], |
106 tagComparator=tag_comparator, | 90 tagComparator=tag_comparator, |
107 enable_http_status_push=active_master_cls.is_production_host) | 91 enable_http_status_push=active_master_cls.is_production_host) |
108 | 92 |
109 # TODO: AutoSetupMaster's settings for the following are too low to be | 93 # TODO: AutoSetupMaster's settings for the following are too low to be |
110 # useful for most projets. We should fix that. | 94 # useful for most projets. We should fix that. |
111 c['buildHorizon'] = 3000 | 95 c['buildHorizon'] = 3000 |
112 c['logHorizon'] = 3000 | 96 c['logHorizon'] = 3000 |
113 # Must be at least 2x the number of slaves. | 97 # Must be at least 2x the number of slaves. |
114 c['eventHorizon'] = 200 | 98 c['eventHorizon'] = 200 |
OLD | NEW |