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

Side by Side Diff: infra/services/builder_alerts/alert_builder.py

Issue 2186673003: Remove logging and metrics from builder alerts code (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Also remove in chromium_try_flakes Created 4 years, 4 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 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 import argparse 4 import argparse
5 import json 5 import json
6 import logging 6 import logging
7 import multiprocessing 7 import multiprocessing
8 import os 8 import os
9 import re 9 import re
10 import sys 10 import sys
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 341
342 342
343 def alerts_for_master(cache, master_url, master_json, old_alerts, 343 def alerts_for_master(cache, master_url, master_json, old_alerts,
344 builder_name_filter=None, jobs=1): # pragma: no cover 344 builder_name_filter=None, jobs=1): # pragma: no cover
345 active_builds = [] 345 active_builds = []
346 for slave in master_json['slaves'].values(): 346 for slave in master_json['slaves'].values():
347 for build in slave['runningBuilds']: 347 for build in slave['runningBuilds']:
348 active_builds.append(build) 348 active_builds.append(build)
349 349
350 def process_builder(builder_name): 350 def process_builder(builder_name):
351 logging.debug('Thread for builder %s has started', builder_name)
352 try: 351 try:
353 if builder_name_filter and builder_name_filter not in builder_name: 352 if builder_name_filter and builder_name_filter not in builder_name:
354 return None 353 return None
355 354
356 builder_json = master_json['builders'][builder_name] 355 builder_json = master_json['builders'][builder_name]
357 356
358 # cachedBuilds will include runningBuilds. 357 # cachedBuilds will include runningBuilds.
359 recent_build_ids = builder_json['cachedBuilds'] 358 recent_build_ids = builder_json['cachedBuilds']
360 359
361 if not recent_build_ids: 360 if not recent_build_ids:
362 return None 361 return None
363 362
364 buildbot.warm_build_cache(cache, master_url, builder_name, 363 buildbot.warm_build_cache(cache, master_url, builder_name,
365 recent_build_ids, active_builds) 364 recent_build_ids, active_builds)
366 return alerts_for_builder(cache, master_url, builder_name, 365 return alerts_for_builder(cache, master_url, builder_name,
367 recent_build_ids, old_alerts) 366 recent_build_ids, old_alerts)
368 except: 367 except:
369 # Put all exception text into an exception and raise that so it doesn't 368 # Put all exception text into an exception and raise that so it doesn't
370 # get eaten by the multiprocessing code. 369 # get eaten by the multiprocessing code.
371 raise Exception(''.join(traceback.format_exception(*sys.exc_info()))) 370 raise Exception(''.join(traceback.format_exception(*sys.exc_info())))
372 finally:
373 logging.debug('Thread for builder %s has finished', builder_name)
374 371
375 pool = multiprocessing.dummy.Pool(processes=jobs) 372 pool = multiprocessing.dummy.Pool(processes=jobs)
376 logging.debug('Processing all builders via thread pool')
377 builder_alerts = pool.map(process_builder, master_json['builders'].keys()) 373 builder_alerts = pool.map(process_builder, master_json['builders'].keys())
378 logging.debug('Closing all threads in builder thread pool')
379 pool.close() 374 pool.close()
380 pool.join() 375 pool.join()
381 logging.debug('Joined all threads in builder thread pool')
382 376
383 alerts = [] 377 alerts = []
384 for alert in builder_alerts: 378 for alert in builder_alerts:
385 if alert: 379 if alert:
386 alerts.extend(alert) 380 alerts.extend(alert)
387 381
388 logging.debug('Computing alerts_for_stale_master_data') 382 logging.debug('Computing alerts_for_stale_master_data')
389 stale_master_data_alert = alert_for_stale_master_data(master_url, master_json) 383 stale_master_data_alert = alert_for_stale_master_data(master_url, master_json)
390 logging.debug('Finished alerts_for_master') 384 logging.debug('Finished alerts_for_master')
391 return (alerts, stale_master_data_alert) 385 return (alerts, stale_master_data_alert)
(...skipping 17 matching lines...) Expand all
409 master_url = match.group('master_url') 403 master_url = match.group('master_url')
410 builder_name = urllib.unquote_plus(match.group('builder_name')) 404 builder_name = urllib.unquote_plus(match.group('builder_name'))
411 master_json = buildbot.fetch_master_json(master_url) 405 master_json = buildbot.fetch_master_json(master_url)
412 # This is kinda a hack, but uses more of our existing code this way: 406 # This is kinda a hack, but uses more of our existing code this way:
413 alerts = alerts_for_master(cache, master_url, master_json, builder_name) 407 alerts = alerts_for_master(cache, master_url, master_json, builder_name)
414 print json.dumps(alerts[0], indent=1) 408 print json.dumps(alerts[0], indent=1)
415 409
416 410
417 if __name__ == '__main__': 411 if __name__ == '__main__':
418 sys.exit(main(sys.argv[1:])) 412 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « infra/services/builder_alerts/__main__.py ('k') | infra/services/builder_alerts/crbug_issues.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698