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

Side by Side Diff: infra/libs/buildbot/master.py

Issue 1128783003: Add master_manager_launch script which launches master_manager scripts for each master on a host. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Add coverage. Created 5 years, 7 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 """Get information about a buildbot master and manipulate it.""" 5 """Get information about a buildbot master and manipulate it."""
6 6
7 7
8 import errno 8 import errno
9 import os 9 import os
10 import json 10 import json
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 """ 86 """
87 last_boot = get_last_boot(directory) 87 last_boot = get_last_boot(directory)
88 last_no_new_builds = _get_last_action(directory, 'make no-new-builds') 88 last_no_new_builds = _get_last_action(directory, 'make no-new-builds')
89 if not last_no_new_builds: 89 if not last_no_new_builds:
90 return None 90 return None
91 if last_boot > last_no_new_builds: 91 if last_boot > last_no_new_builds:
92 return None 92 return None
93 return last_no_new_builds 93 return last_no_new_builds
94 94
95 95
96 def get_mastermap_data(directory): 96 def _call_mastermap(build_dir):
97 """Get mastermap JSON from a master directory.""" 97 """Given a build/ directory, obtain the full mastermap.json.
98 98
99 build_dir = os.path.join(directory, os.pardir, os.pardir, os.pardir, 'build') 99 This checks if build_internal/ is checked out next to build/ and uses
100 mastermap_internal.py if present.
101 """
100 runit = os.path.join(build_dir, 'scripts', 'tools', 'runit.py') 102 runit = os.path.join(build_dir, 'scripts', 'tools', 'runit.py')
101 build_internal_dir = os.path.join(build_dir, os.pardir, 'build_internal') 103 build_internal_dir = os.path.join(build_dir, os.pardir, 'build_internal')
102 104
103 script_path = os.path.join(build_dir, 'scripts', 'tools', 'mastermap.py') 105 script_path = os.path.join(build_dir, 'scripts', 'tools', 'mastermap.py')
104 if os.path.exists(build_internal_dir): 106 if os.path.exists(build_internal_dir):
105 script_path = os.path.join( 107 script_path = os.path.join(
106 build_internal_dir, 'scripts', 'tools', 'mastermap_internal.py') 108 build_internal_dir, 'scripts', 'tools', 'mastermap_internal.py')
107 109
108 script_data = json.loads(subprocess.check_output( 110 return json.loads(subprocess.check_output(
iannucci 2015/05/06 23:48:05 if this gets called a bunch in the same process, i
ghost stip (do not use) 2015/05/07 06:50:56 only twice. I'd like to introduce a @memoize decor
109 [runit, script_path, '-f', 'json'])) 111 [runit, script_path, '-f', 'json']))
110 112
113
114 def get_mastermap_for_host(build_dir, hostname):
115 """Get mastermap JSON for all masters on a specific host."""
116 script_data = _call_mastermap(build_dir)
117 return [x for x in script_data if x.get('fullhost') == hostname]
118
119
120 def get_mastermap_data(directory):
121 """Get mastermap JSON for a specific master."""
122
123 build_dir = os.path.join(directory, os.pardir, os.pardir, os.pardir, 'build')
iannucci 2015/05/06 23:48:05 would much rather use dirname than pardir (assumin
ghost stip (do not use) 2015/05/07 06:50:57 Done.
124 script_data = _call_mastermap(build_dir)
125
111 short_dirname = os.path.basename(directory) 126 short_dirname = os.path.basename(directory)
112 matches = [x for x in script_data if x.get('dirname') == short_dirname] 127 matches = [x for x in script_data if x.get('dirname') == short_dirname]
113 assert len(matches) < 2, ( 128 assert len(matches) < 2, (
114 'Multiple masters were found with the same master directory.') 129 'Multiple masters were found with the same master directory.')
115 if matches: 130 if matches:
116 return matches[0] 131 return matches[0]
117 return None 132 return None
118 133
119 134
120 def _get_master_web_port(directory): 135 def _get_master_web_port(directory):
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 elif action_item == MakeStop: 202 elif action_item == MakeStop:
188 yield cmd_dict(['make', 'stop'], 'make') 203 yield cmd_dict(['make', 'stop'], 'make')
189 elif action_item == MakeWait: 204 elif action_item == MakeWait:
190 yield cmd_dict(['make', 'wait'], 'make') 205 yield cmd_dict(['make', 'wait'], 'make')
191 elif action_item == MakeStart: 206 elif action_item == MakeStart:
192 yield cmd_dict(['make', 'start'], 'make') 207 yield cmd_dict(['make', 'start'], 'make')
193 elif action_item == MakeNoNewBuilds: 208 elif action_item == MakeNoNewBuilds:
194 yield cmd_dict(['make', 'no-new-builds'], 'make') 209 yield cmd_dict(['make', 'no-new-builds'], 'make')
195 else: 210 else:
196 raise ValueError('Invalid action item %s' % action_item) 211 raise ValueError('Invalid action item %s' % action_item)
OLDNEW
« no previous file with comments | « no previous file | infra/libs/buildbot/test/master_test.py » ('j') | infra/tools/master_manager_launcher/__main__.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698