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 # FIXME: Everything in this file belongs in gatekeeper_ng_config.py | 5 # FIXME: Everything in this file belongs in gatekeeper_ng_config.py |
6 | 6 |
7 import logging | 7 import logging |
8 | 8 |
9 import infra.tools.builder_alerts.buildbot | |
agable
2014/09/04 14:22:31
Since you only use one thing, could do
from infra.
Sergiy Byelozyorov
2014/09/05 12:59:06
Done.
| |
9 | 10 |
10 def excluded_builders(master_config): | 11 def excluded_builders(master_config): |
11 return master_config[0].get('*', {}).get('excluded_builders', set()) | 12 return master_config[0].get('*', {}).get('excluded_builders', set()) |
12 | 13 |
13 | 14 |
14 # pylint: disable=C0301 | 15 def tree_for_master(master_url, gatekeeper_trees_config): |
15 # FIXME: This is currently baked into: | 16 """Returns name of the tree for a given master or its name on failure. |
agable
2014/09/04 14:22:31
"Get the name of the tree for a given master url,
Sergiy Byelozyorov
2014/09/05 12:59:06
Done.
| |
16 # https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/slave/ gatekeeper_launch.py | 17 |
17 # http://crbug.com/394961 | 18 Retuns: |
agable
2014/09/04 14:22:31
Don't really need a "returns" section when the fir
Sergiy Byelozyorov
2014/09/05 12:59:06
Done.
| |
18 MASTER_CONFIG = { | 19 Tree name of master name if the master url is not present in gatekeeper |
agable
2014/09/04 14:22:31
tree name *or*
Sergiy Byelozyorov
2014/09/05 12:59:06
Acknowledged.
| |
19 'chromium-status': [ | 20 config. |
20 'chromium', | 21 """ |
21 'chromium.chrome', | 22 for tree_name, tree_config in gatekeeper_trees_config.iteritems(): |
22 'chromium.chromiumos', | 23 if master_url in tree_config['masters']: |
23 'chromium.gpu', | 24 return tree_name |
24 'chromium.linux', | 25 return infra.tools.builder_alerts.buildbot.master_name_from_url(master_url) |
agable
2014/09/04 14:22:31
Why is this fallback now necessary?
Sergiy Byelozyorov
2014/09/05 12:59:07
Master info may not be in a config file. In this c
| |
25 'chromium.mac', | |
26 'chromium.memory', | |
27 'chromium.win', | |
28 ], | |
29 'blink-status': [ | |
30 'chromium.webkit', | |
31 ], | |
32 } | |
33 | 26 |
34 | 27 |
35 def tree_for_master(master_name): | 28 def apply_gatekeeper_rules(alerts, gatekeeper, gatekeeper_trees): |
36 for tree_name, master_names in MASTER_CONFIG.items(): | 29 filtered_alerts = [] |
37 if master_name in master_names: | 30 for alert in alerts: |
38 return tree_name | 31 master_url = alert['master_url'] |
32 config = gatekeeper.get(master_url) | |
33 if not config: | |
34 # Unclear if this should be set or not? | |
35 # alert['would_close_tree'] = False | |
36 filtered_alerts.append(alert) | |
37 continue | |
38 if alert['builder_name'] in excluded_builders(config): | |
39 continue | |
40 alert['would_close_tree'] = would_close_tree( | |
41 config, alert['builder_name'], alert['step_name']) | |
42 alert['tree'] = tree_for_master(master_url, gatekeeper_trees) | |
43 filtered_alerts.append(alert) | |
44 return filtered_alerts | |
45 | |
46 | |
47 def fetch_master_urls(gatekeeper, args): | |
48 # Currently using gatekeeper.json, but could use: | |
49 # https://chrome-infra-stats.appspot.com/_ah/api#p/stats/v1/stats.masters.list | |
tandrii(chromium)
2014/09/04 14:21:06
nit: I thought comments should end with period.
Sergiy Byelozyorov
2014/09/05 12:59:07
Yeah, but URL takes entire line and adding a perio
| |
50 master_urls = gatekeeper.keys() | |
51 if args.master_filter: | |
52 master_urls = [url for url in master_urls if args.master_filter not in url] | |
53 return master_urls | |
39 | 54 |
40 | 55 |
41 def would_close_tree(master_config, builder_name, step_name): | 56 def would_close_tree(master_config, builder_name, step_name): |
42 # FIXME: Section support should be removed: | 57 # FIXME: Section support should be removed: |
43 master_config = master_config[0] | 58 master_config = master_config[0] |
44 builder_config = master_config.get(builder_name, {}) | 59 builder_config = master_config.get(builder_name, {}) |
45 if not builder_config: | 60 if not builder_config: |
46 builder_config = master_config.get('*', {}) | 61 builder_config = master_config.get('*', {}) |
47 | 62 |
48 # close_tree is currently unused in gatekeeper.json but planned to be. | 63 # close_tree is currently unused in gatekeeper.json but planned to be. |
(...skipping 21 matching lines...) Expand all Loading... | |
70 | 85 |
71 # A '*' in any of the above types means it applies to all steps. | 86 # A '*' in any of the above types means it applies to all steps. |
72 if '*' in closing_steps: | 87 if '*' in closing_steps: |
73 return True | 88 return True |
74 | 89 |
75 if step_name in closing_steps: | 90 if step_name in closing_steps: |
76 return True | 91 return True |
77 | 92 |
78 logging.debug('%s not in closing_steps: %s' % (step_name, closing_steps)) | 93 logging.debug('%s not in closing_steps: %s' % (step_name, closing_steps)) |
79 return False | 94 return False |
OLD | NEW |