| OLD | NEW |
| 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 import json | 5 import json |
| 6 import logging | 6 import logging |
| 7 | 7 |
| 8 from base_handler import BaseHandler | 8 from base_handler import BaseHandler |
| 9 from base_handler import Permission | 9 from base_handler import Permission |
| 10 from common import constants |
| 10 from common.http_client_appengine import HttpClientAppengine | 11 from common.http_client_appengine import HttpClientAppengine |
| 11 from waterfall import buildbot | 12 from waterfall import buildbot |
| 12 from waterfall import build_failure_analysis_pipelines | 13 from waterfall import build_failure_analysis_pipelines |
| 13 from waterfall import waterfall_config | 14 from waterfall import waterfall_config |
| 14 | 15 |
| 15 | 16 |
| 16 _ALERTS_SOURCE_URL = 'https://sheriff-o-matic.appspot.com/alerts' | |
| 17 _BUILD_FAILURE_ANALYSIS_TASKQUEUE = 'build-failure-analysis-queue' | |
| 18 | |
| 19 | |
| 20 def _GetLatestBuildFailures(http_client): | 17 def _GetLatestBuildFailures(http_client): |
| 21 """Returns latest build failures from alerts in Sheriff-o-Matic. | 18 """Returns latest build failures from alerts in Sheriff-o-Matic. |
| 22 | 19 |
| 23 Returns: | 20 Returns: |
| 24 A list of following form: | 21 A list of following form: |
| 25 [ | 22 [ |
| 26 { | 23 { |
| 27 'master_name': 'm', | 24 'master_name': 'm', |
| 28 'builder_name': 'b', | 25 'builder_name': 'b', |
| 29 'build_number': 123, | 26 'build_number': 123, |
| 30 'failed_steps': ['a', 'b'] | 27 'failed_steps': ['a', 'b'] |
| 31 }, | 28 }, |
| 32 ... | 29 ... |
| 33 ] | 30 ] |
| 34 """ | 31 """ |
| 35 status_code, content = http_client.Get(_ALERTS_SOURCE_URL, timeout_seconds=30) | 32 status_code, content = http_client.Get( |
| 33 constants.WATERFALL_ALERTS_URL, timeout_seconds=30) |
| 36 if status_code != 200: | 34 if status_code != 200: |
| 37 logging.error('Failed to pull alerts from Sheriff-o-Matic.') | 35 logging.error('Failed to pull alerts from Sheriff-o-Matic.') |
| 38 return [] | 36 return [] |
| 39 | 37 |
| 40 data = json.loads(content) | 38 data = json.loads(content) |
| 41 alerts = data.get('alerts', []) | 39 alerts = data.get('alerts', []) |
| 42 | 40 |
| 43 # Explicit delete: sometimes the content pulled from SoM could be as big as | 41 # Explicit delete: sometimes the content pulled from SoM could be as big as |
| 44 # ~30MB and the parsed json result as big as 150+MB. | 42 # ~30MB and the parsed json result as big as 150+MB. |
| 45 del content | 43 del content |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 def HandleGet(self): | 86 def HandleGet(self): |
| 89 build_failures = _GetLatestBuildFailures(self.HTTP_CLIENT) | 87 build_failures = _GetLatestBuildFailures(self.HTTP_CLIENT) |
| 90 | 88 |
| 91 for build_failure in build_failures: | 89 for build_failure in build_failures: |
| 92 build_failure_analysis_pipelines.ScheduleAnalysisIfNeeded( | 90 build_failure_analysis_pipelines.ScheduleAnalysisIfNeeded( |
| 93 build_failure['master_name'], | 91 build_failure['master_name'], |
| 94 build_failure['builder_name'], | 92 build_failure['builder_name'], |
| 95 build_failure['build_number'], | 93 build_failure['build_number'], |
| 96 failed_steps=build_failure['failed_steps'], | 94 failed_steps=build_failure['failed_steps'], |
| 97 force=False, | 95 force=False, |
| 98 queue_name=_BUILD_FAILURE_ANALYSIS_TASKQUEUE) | 96 queue_name=constants.WATERFALL_ANALYSIS_QUEUE) |
| OLD | NEW |