| OLD | NEW |
| 1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 """Functions specific to handle goma related info. | 5 """Functions specific to handle goma related info. |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 import base64 | 8 import base64 |
| 9 import datetime | 9 import datetime |
| 10 import getpass | 10 import getpass |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 262 |
| 263 | 263 |
| 264 def GetCompilerProxyStartTime(): | 264 def GetCompilerProxyStartTime(): |
| 265 """Returns datetime instance of the latest compiler_proxy start time.""" | 265 """Returns datetime instance of the latest compiler_proxy start time.""" |
| 266 with open(GetLatestGomaCompilerProxyInfo()) as f: | 266 with open(GetLatestGomaCompilerProxyInfo()) as f: |
| 267 matched = TIMESTAMP_PATTERN.search(f.readline()) | 267 matched = TIMESTAMP_PATTERN.search(f.readline()) |
| 268 if matched: | 268 if matched: |
| 269 return datetime.datetime.strptime(matched.group(1), TIMESTAMP_FORMAT) | 269 return datetime.datetime.strptime(matched.group(1), TIMESTAMP_FORMAT) |
| 270 | 270 |
| 271 | 271 |
| 272 def SendGomaTsMon(json_file, exit_status, | 272 def SendGomaTsMon(json_file, exit_status): |
| 273 builder='unknown', master='unknown', slave='unknown', | |
| 274 clobber=''): | |
| 275 """Send latest Goma status to ts_mon. | 273 """Send latest Goma status to ts_mon. |
| 276 | 274 |
| 277 Args: | 275 Args: |
| 278 json_file: json filename string that has goma_ctl.py jsonstatus. | 276 json_file: json filename string that has goma_ctl.py jsonstatus. |
| 279 exit_status: integer exit status of the build. | 277 exit_status: integer exit status of the build. |
| 280 """ | 278 """ |
| 281 json_statuses = {} | 279 json_statuses = {} |
| 282 try: | 280 try: |
| 283 with open(json_file) as f: | 281 with open(json_file) as f: |
| 284 json_statuses = json.load(f) | 282 json_statuses = json.load(f) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 306 infra_status['ping_status_code'] != 200 or | 304 infra_status['ping_status_code'] != 200 or |
| 307 infra_status.get('num_user_error', 0) > 0): | 305 infra_status.get('num_user_error', 0) > 0): |
| 308 result = 'exception' | 306 result = 'exception' |
| 309 | 307 |
| 310 num_failure = 0 | 308 num_failure = 0 |
| 311 ping_status_code = 0 | 309 ping_status_code = 0 |
| 312 if infra_status: | 310 if infra_status: |
| 313 num_failure = infra_status['num_exec_compiler_proxy_failure'] | 311 num_failure = infra_status['num_exec_compiler_proxy_failure'] |
| 314 ping_status_code = infra_status['ping_status_code'] | 312 ping_status_code = infra_status['ping_status_code'] |
| 315 | 313 |
| 314 clobber = 0 |
| 315 if os.environ.get('BUILDBOT_CLOBBER'): |
| 316 clobber = 1 |
| 317 |
| 316 counter = { | 318 counter = { |
| 317 'name': 'goma/failure', | 319 'name': 'goma/failure', |
| 318 'value': num_failure, | 320 'value': num_failure, |
| 319 'builder': builder, | 321 'builder': os.environ.get('BUILDBOT_BUILDERNAME', 'unknown'), |
| 320 'master': master, | 322 'master': os.environ.get('BUILDBOT_MASTERNAME', 'unknown'), |
| 321 'slave': slave, | 323 'slave': os.environ.get('BUILDBOT_SLAVENAME', 'unknown'), |
| 322 'clobber': 1 if clobber else 0, | 324 'clobber': clobber, |
| 323 'os': chromium_utils.PlatformName(), | 325 'os': chromium_utils.PlatformName(), |
| 324 'ping_status_code': ping_status_code, | 326 'ping_status_code': ping_status_code, |
| 325 'result': result} | 327 'result': result} |
| 326 start_time = GetCompilerProxyStartTime() | 328 start_time = GetCompilerProxyStartTime() |
| 327 if start_time: | 329 if start_time: |
| 328 counter['start_time'] = int(time.mktime(start_time.timetuple())) | 330 counter['start_time'] = int(time.mktime(start_time.timetuple())) |
| 329 run_cmd = PLATFORM_RUN_CMD.get(os.name) | 331 run_cmd = PLATFORM_RUN_CMD.get(os.name) |
| 330 if not run_cmd: | 332 if not run_cmd: |
| 331 print 'Unknown os.name: %s' % os.name | 333 print 'Unknown os.name: %s' % os.name |
| 332 return | 334 return |
| (...skipping 13 matching lines...) Expand all Loading... |
| 346 retcode = chromium_utils.RunCommand( | 348 retcode = chromium_utils.RunCommand( |
| 347 cmd, filter_obj=cmd_filter, | 349 cmd, filter_obj=cmd_filter, |
| 348 max_time=30) | 350 max_time=30) |
| 349 if retcode: | 351 if retcode: |
| 350 print('Execution of send_ts_mon_values failed with code %s' | 352 print('Execution of send_ts_mon_values failed with code %s' |
| 351 % retcode) | 353 % retcode) |
| 352 print '\n'.join(cmd_filter.text) | 354 print '\n'.join(cmd_filter.text) |
| 353 | 355 |
| 354 except Exception as ex: | 356 except Exception as ex: |
| 355 print('error while sending ts mon json_file=%s: %s' % (json_file, ex)) | 357 print('error while sending ts mon json_file=%s: %s' % (json_file, ex)) |
| OLD | NEW |