| 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.changes.filter import ChangeFilter | 8 from buildbot.changes.filter import ChangeFilter |
| 9 from buildbot.schedulers.basic import SingleBranchScheduler | 9 from buildbot.schedulers.basic import SingleBranchScheduler |
| 10 from buildbot.schedulers.timed import Nightly | 10 from buildbot.schedulers.timed import Nightly |
| 11 from buildbot.status.mail import MailNotifier | 11 from buildbot.status.mail import MailNotifier |
| 12 from buildbot import util | 12 from buildbot import util |
| 13 | 13 |
| 14 from config_bootstrap import Master | 14 from config_bootstrap import Master |
| 15 | 15 |
| 16 from common import chromium_utils | 16 from common import chromium_utils |
| 17 | 17 |
| 18 from master import gitiles_poller | 18 from master import gitiles_poller |
| 19 from master import master_utils | 19 from master import master_utils |
| 20 from master import repo_poller | 20 from master import repo_poller |
| 21 from master import slaves_list | 21 from master import slaves_list |
| 22 from master.factory import annotator_factory | 22 from master.factory import annotator_factory |
| 23 from master.factory import remote_run_factory |
| 23 | 24 |
| 24 | 25 |
| 25 def PopulateBuildmasterConfig(BuildmasterConfig, builders_path, | 26 def PopulateBuildmasterConfig(BuildmasterConfig, builders_path, |
| 26 active_master_cls): | 27 active_master_cls): |
| 27 """Read builders_path and populate a build master config dict.""" | 28 """Read builders_path and populate a build master config dict.""" |
| 28 builders = chromium_utils.ReadBuildersFile(builders_path) | 29 builders = chromium_utils.ReadBuildersFile(builders_path) |
| 29 _Populate(BuildmasterConfig, builders, active_master_cls) | 30 _Populate(BuildmasterConfig, builders, active_master_cls) |
| 30 | 31 |
| 31 | 32 |
| 32 def _Populate(BuildmasterConfig, builders, active_master_cls): | 33 def _Populate(BuildmasterConfig, builders, active_master_cls): |
| 33 m_annotator = annotator_factory.AnnotatorFactory(active_master_cls) | 34 m_annotator = annotator_factory.AnnotatorFactory(active_master_cls) |
| 34 | 35 |
| 35 c = BuildmasterConfig | 36 c = BuildmasterConfig |
| 36 c['logCompressionLimit'] = False | 37 c['logCompressionLimit'] = False |
| 37 c['projectName'] = active_master_cls.project_name | 38 c['projectName'] = active_master_cls.project_name |
| 38 c['projectURL'] = Master.project_url | 39 c['projectURL'] = Master.project_url |
| 39 c['buildbotURL'] = active_master_cls.buildbot_url | 40 c['buildbotURL'] = active_master_cls.buildbot_url |
| 40 | 41 |
| 41 # This sets c['db_url'] to the database connect string in found in | 42 # This sets c['db_url'] to the database connect string in found in |
| 42 # the .dbconfig in the master directory, if it exists. If this is | 43 # the .dbconfig in the master directory, if it exists. If this is |
| 43 # a production host, it must exist. | 44 # a production host, it must exist. |
| 44 chromium_utils.DatabaseSetup( | 45 chromium_utils.DatabaseSetup( |
| 45 c, | 46 c, |
| 46 require_dbconfig=active_master_cls.is_production_host) | 47 require_dbconfig=active_master_cls.is_production_host) |
| 47 | 48 |
| 48 c['builders'] = _ComputeBuilders(builders, m_annotator) | 49 c['builders'] = _ComputeBuilders(builders, m_annotator, active_master_cls) |
| 49 | 50 |
| 50 c['schedulers'] = _ComputeSchedulers(builders) | 51 c['schedulers'] = _ComputeSchedulers(builders) |
| 51 | 52 |
| 52 c['change_source'], tag_comparator = _ComputeChangeSourceAndTagComparator( | 53 c['change_source'], tag_comparator = _ComputeChangeSourceAndTagComparator( |
| 53 builders) | 54 builders) |
| 54 | 55 |
| 55 # The 'slaves' list defines the set of allowable buildslaves. List all the | 56 # The 'slaves' list defines the set of allowable buildslaves. List all the |
| 56 # slaves registered to a builder. Remove dupes. | 57 # slaves registered to a builder. Remove dupes. |
| 57 c['slaves'] = master_utils.AutoSetupSlaves( | 58 c['slaves'] = master_utils.AutoSetupSlaves( |
| 58 c['builders'], | 59 c['builders'], |
| (...skipping 20 matching lines...) Expand all Loading... |
| 79 enable_http_status_push=active_master_cls.is_production_host) | 80 enable_http_status_push=active_master_cls.is_production_host) |
| 80 | 81 |
| 81 # TODO: AutoSetupMaster's settings for the following are too low to be | 82 # TODO: AutoSetupMaster's settings for the following are too low to be |
| 82 # useful for most projects. We should fix that. | 83 # useful for most projects. We should fix that. |
| 83 c['buildHorizon'] = 3000 | 84 c['buildHorizon'] = 3000 |
| 84 c['logHorizon'] = 3000 | 85 c['logHorizon'] = 3000 |
| 85 # Must be at least 2x the number of slaves. | 86 # Must be at least 2x the number of slaves. |
| 86 c['eventHorizon'] = 200 | 87 c['eventHorizon'] = 200 |
| 87 | 88 |
| 88 | 89 |
| 89 def _ComputeBuilders(builders, m_annotator): | 90 def _ComputeBuilders(builders, m_annotator, active_master_cls): |
| 90 actual_builders = [] | 91 actual_builders = [] |
| 91 | 92 |
| 92 default_properties = builders.get('default_properties') | 93 default_properties = builders.get('default_properties') |
| 93 | 94 |
| 94 def cmp_fn(a, b): | 95 def cmp_fn(a, b): |
| 95 a_cat = builders['builders'][a].get('category') | 96 a_cat = builders['builders'][a].get('category') |
| 96 b_cat = builders['builders'][b].get('category') | 97 b_cat = builders['builders'][b].get('category') |
| 97 if a_cat != b_cat: | 98 if a_cat != b_cat: |
| 98 return 1 if a_cat > b_cat else -1 | 99 return 1 if a_cat > b_cat else -1 |
| 99 if a != b: | 100 if a != b: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 113 | 114 |
| 114 slavebuilddir = builder_data.get('slavebuilddir', | 115 slavebuilddir = builder_data.get('slavebuilddir', |
| 115 util.safeTranslate(builder_name)) | 116 util.safeTranslate(builder_name)) |
| 116 | 117 |
| 117 if default_properties: | 118 if default_properties: |
| 118 props = default_properties.copy() | 119 props = default_properties.copy() |
| 119 props.update(builder_data.get('properties', {})) | 120 props.update(builder_data.get('properties', {})) |
| 120 else: | 121 else: |
| 121 props = builder_data.get('properties') | 122 props = builder_data.get('properties') |
| 122 | 123 |
| 123 factory = m_annotator.BaseFactory( | 124 if builder_data.get('use_remote_run'): |
| 124 recipe=builder_data['recipe'], | 125 factory = remote_run_factory.RemoteRunFactory( |
| 125 max_time=builder_data.get('builder_timeout_s'), | 126 active_master=active_master_cls, |
| 126 factory_properties=props, | 127 repository=builder_data.get( |
| 127 ) | 128 'repository', builders.get('default_remote_run_repository')), |
| 129 recipe=builder_data['recipe'], |
| 130 max_time=builder_data.get('builder_timeout_s'), |
| 131 factory_properties=props, |
| 132 ) |
| 133 else: |
| 134 factory = m_annotator.BaseFactory( |
| 135 recipe=builder_data['recipe'], |
| 136 max_time=builder_data.get('builder_timeout_s'), |
| 137 factory_properties=props, |
| 138 ) |
| 128 actual_builders.append({ | 139 actual_builders.append({ |
| 129 'auto_reboot': builder_data.get('auto_reboot', True), | 140 'auto_reboot': builder_data.get('auto_reboot', True), |
| 130 'mergeRequests': merge_requests, | 141 'mergeRequests': merge_requests, |
| 131 'name': builder_name, | 142 'name': builder_name, |
| 132 'factory': factory, | 143 'factory': factory, |
| 133 'slavebuilddir': slavebuilddir, | 144 'slavebuilddir': slavebuilddir, |
| 134 'slavenames': chromium_utils.GetSlaveNamesForBuilder(builders, | 145 'slavenames': chromium_utils.GetSlaveNamesForBuilder(builders, |
| 135 builder_name), | 146 builder_name), |
| 136 'category': builder_data.get('category'), | 147 'category': builder_data.get('category'), |
| 137 'trybot': builder_data.get('trybot'), | 148 'trybot': builder_data.get('trybot'), |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 pollInterval=300, | 239 pollInterval=300, |
| 229 revlinktmpl=rev_link_template)) | 240 revlinktmpl=rev_link_template)) |
| 230 | 241 |
| 231 # We have to set the tag_comparator to something, but if we have multiple | 242 # We have to set the tag_comparator to something, but if we have multiple |
| 232 # repos, the tag_comparator will not work properly (it's meaningless). | 243 # repos, the tag_comparator will not work properly (it's meaningless). |
| 233 # It's not clear if there's a good answer to this. | 244 # It's not clear if there's a good answer to this. |
| 234 if change_source: | 245 if change_source: |
| 235 tag_comparator = change_source[0].comparator | 246 tag_comparator = change_source[0].comparator |
| 236 | 247 |
| 237 return change_source, tag_comparator | 248 return change_source, tag_comparator |
| OLD | NEW |