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

Side by Side Diff: scheduler/drone_utility.py

Issue 4823005: Merge remote branch 'cros/upstream' into tempbranch (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: patch Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « scheduler/drone_manager.py ('k') | scheduler/monitor_db.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 import pickle, subprocess, os, shutil, socket, sys, time, signal, getpass 3 import pickle, subprocess, os, shutil, socket, sys, time, signal, getpass
4 import datetime, traceback, tempfile, itertools, logging 4 import datetime, traceback, tempfile, itertools, logging
5 import common 5 import common
6 from autotest_lib.client.common_lib import utils, global_config, error 6 from autotest_lib.client.common_lib import utils, global_config, error
7 from autotest_lib.server import hosts, subcommand 7 from autotest_lib.server import hosts, subcommand
8 from autotest_lib.scheduler import email_manager, scheduler_config 8 from autotest_lib.scheduler import email_manager, scheduler_config
9 9
10 # An environment variable we add to the environment to enable us to 10 # An environment variable we add to the environment to enable us to
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ['/bin/ps', 'x', '-o', ','.join(cls._PS_ARGS)], 96 ['/bin/ps', 'x', '-o', ','.join(cls._PS_ARGS)],
97 stdout=subprocess.PIPE) 97 stdout=subprocess.PIPE)
98 ps_output = ps_proc.communicate()[0] 98 ps_output = ps_proc.communicate()[0]
99 99
100 # split each line into the columns output by ps 100 # split each line into the columns output by ps
101 split_lines = [line.split(None, 4) for line in ps_output.splitlines()] 101 split_lines = [line.split(None, 4) for line in ps_output.splitlines()]
102 return (dict(itertools.izip(cls._PS_ARGS, line_components)) 102 return (dict(itertools.izip(cls._PS_ARGS, line_components))
103 for line_components in split_lines) 103 for line_components in split_lines)
104 104
105 105
106 def _refresh_processes(self, command_name, open=open): 106 def _refresh_processes(self, command_name, open=open,
107 site_check_parse=None):
107 # The open argument is used for test injection. 108 # The open argument is used for test injection.
108 check_mark = global_config.global_config.get_config_value( 109 check_mark = global_config.global_config.get_config_value(
109 'SCHEDULER', 'check_processes_for_dark_mark', bool, False) 110 'SCHEDULER', 'check_processes_for_dark_mark', bool, False)
110 processes = [] 111 processes = []
111 for info in self._get_process_info(): 112 for info in self._get_process_info():
112 if info['comm'] == command_name: 113 is_parse = (site_check_parse and site_check_parse(info))
114 if info['comm'] == command_name or is_parse:
113 if (check_mark and not 115 if (check_mark and not
114 self._check_pid_for_dark_mark(info['pid'], open=open)): 116 self._check_pid_for_dark_mark(info['pid'], open=open)):
115 self._warn('%(comm)s process pid %(pid)s has no ' 117 self._warn('%(comm)s process pid %(pid)s has no '
116 'dark mark; ignoring.' % info) 118 'dark mark; ignoring.' % info)
117 continue 119 continue
118 processes.append(info) 120 processes.append(info)
119 121
120 return processes 122 return processes
121 123
122 124
(...skipping 18 matching lines...) Expand all
141 Returns a dict containing: 143 Returns a dict containing:
142 * pidfiles: dict mapping pidfile paths to file contents, for pidfiles 144 * pidfiles: dict mapping pidfile paths to file contents, for pidfiles
143 that exist. 145 that exist.
144 * autoserv_processes: list of dicts corresponding to running autoserv 146 * autoserv_processes: list of dicts corresponding to running autoserv
145 processes. each dict contain pid, pgid, ppid, comm, and args (see 147 processes. each dict contain pid, pgid, ppid, comm, and args (see
146 "man ps" for details). 148 "man ps" for details).
147 * parse_processes: likewise, for parse processes. 149 * parse_processes: likewise, for parse processes.
148 * pidfiles_second_read: same info as pidfiles, but gathered after the 150 * pidfiles_second_read: same info as pidfiles, but gathered after the
149 processes are scanned. 151 processes are scanned.
150 """ 152 """
153 site_check_parse = utils.import_site_function(
154 __file__, 'autotest_lib.scheduler.site_drone_utility',
155 'check_parse', lambda x: False)
151 results = { 156 results = {
152 'pidfiles' : self._read_pidfiles(pidfile_paths), 157 'pidfiles' : self._read_pidfiles(pidfile_paths),
153 'autoserv_processes' : self._refresh_processes('autoserv'), 158 'autoserv_processes' : self._refresh_processes('autoserv'),
154 'parse_processes' : self._refresh_processes('parse'), 159 'parse_processes' : self._refresh_processes(
160 'parse', site_check_parse=site_check_parse),
155 'pidfiles_second_read' : self._read_pidfiles(pidfile_paths), 161 'pidfiles_second_read' : self._read_pidfiles(pidfile_paths),
156 } 162 }
157 return results 163 return results
158 164
159 165
160 def kill_process(self, process): 166 def kill_process(self, process):
161 signal_queue = (signal.SIGCONT, signal.SIGTERM, signal.SIGKILL) 167 signal_queue = (signal.SIGCONT, signal.SIGTERM, signal.SIGKILL)
162 utils.nuke_pid(process.pid, signal_queue=signal_queue) 168 utils.nuke_pid(process.pid, signal_queue=signal_queue)
163 169
164 170
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 425
420 def main(): 426 def main():
421 calls = parse_input() 427 calls = parse_input()
422 drone_utility = DroneUtility() 428 drone_utility = DroneUtility()
423 return_value = drone_utility.execute_calls(calls) 429 return_value = drone_utility.execute_calls(calls)
424 return_data(return_value) 430 return_data(return_value)
425 431
426 432
427 if __name__ == '__main__': 433 if __name__ == '__main__':
428 main() 434 main()
OLDNEW
« no previous file with comments | « scheduler/drone_manager.py ('k') | scheduler/monitor_db.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698