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

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: Move to infra/services. 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(
104 os.path.dirname(build_dir), 'build_internal')
102 105
103 script_path = os.path.join(build_dir, 'scripts', 'tools', 'mastermap.py') 106 script_path = os.path.join(build_dir, 'scripts', 'tools', 'mastermap.py')
104 if os.path.exists(build_internal_dir): 107 if os.path.exists(build_internal_dir):
105 script_path = os.path.join( 108 script_path = os.path.join(
106 build_internal_dir, 'scripts', 'tools', 'mastermap_internal.py') 109 build_internal_dir, 'scripts', 'tools', 'mastermap_internal.py')
107 110
108 script_data = json.loads(subprocess.check_output( 111 return json.loads(subprocess.check_output(
109 [runit, script_path, '-f', 'json'])) 112 [runit, script_path, '-f', 'json']))
110 113
114
115 def get_mastermap_for_host(build_dir, hostname):
116 """Get mastermap JSON for all masters on a specific host."""
117 script_data = _call_mastermap(build_dir)
118 return [x for x in script_data if x.get('fullhost') == hostname]
119
120
121 def get_mastermap_data(directory):
122 """Get mastermap JSON for a specific master."""
123
124 build_dir = os.path.join(
125 os.path.dirname(os.path.dirname(os.path.dirname(directory))), 'build')
126 script_data = _call_mastermap(build_dir)
127
111 short_dirname = os.path.basename(directory) 128 short_dirname = os.path.basename(directory)
112 matches = [x for x in script_data if x.get('dirname') == short_dirname] 129 matches = [x for x in script_data if x.get('dirname') == short_dirname]
113 assert len(matches) < 2, ( 130 assert len(matches) < 2, (
114 'Multiple masters were found with the same master directory.') 131 'Multiple masters were found with the same master directory.')
115 if matches: 132 if matches:
116 return matches[0] 133 return matches[0]
117 return None 134 return None
118 135
119 136
120 def _get_master_web_port(directory): 137 def _get_master_web_port(directory):
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 elif action_item == MakeStop: 204 elif action_item == MakeStop:
188 yield cmd_dict(['make', 'stop'], 'make') 205 yield cmd_dict(['make', 'stop'], 'make')
189 elif action_item == MakeWait: 206 elif action_item == MakeWait:
190 yield cmd_dict(['make', 'wait'], 'make') 207 yield cmd_dict(['make', 'wait'], 'make')
191 elif action_item == MakeStart: 208 elif action_item == MakeStart:
192 yield cmd_dict(['make', 'start'], 'make') 209 yield cmd_dict(['make', 'start'], 'make')
193 elif action_item == MakeNoNewBuilds: 210 elif action_item == MakeNoNewBuilds:
194 yield cmd_dict(['make', 'no-new-builds'], 'make') 211 yield cmd_dict(['make', 'no-new-builds'], 'make')
195 else: 212 else:
196 raise ValueError('Invalid action item %s' % action_item) 213 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/services/master_manager_launcher/__main__.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698