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

Side by Side Diff: appengine/findit/crash/findit_for_client.py

Issue 2299883005: [Findit] Add findit_for_client to do analysis based on client_id (Closed)
Patch Set: Add an if else. Created 4 years, 3 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
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import copy
6 import json
7 import logging
8
9 from google.appengine.api import app_identity
10 from google.appengine.ext import ndb
11
12 from common import time_util
13 from crash import findit_for_fracas
14 from crash.type_enums import CrashClient
15 from model import analysis_status
16 from model.crash.crash_config import CrashConfig
17 from model.crash.fracas_crash_analysis import FracasCrashAnalysis
18
19 _FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE = '%s/crash/fracas-result-feedback?key=%s'
20
21
22 def CheckPolicyForClient(crash_identifiers, chrome_version, signature,
23 client_id, platform, stack_trace, customized_data):
24 """Checks if the args pass the client policy or not, update the parameters
25 if needed."""
26 crash_config = CrashConfig.Get()
27
28 # Cracas and Fracas share the sampe policy.
29 if client_id == CrashClient.FRACAS or client_id == CrashClient.CRACAS:
30 if platform not in crash_config.fracas.get(
31 'supported_platform_list_by_channel', {}).get(
32 customized_data.get('channel'), []):
33 # Bail out if either the channel or platform is not supported yet.
34 logging.info('Ananlysis of channel %s, platform %s is not supported. '
35 'No analysis is scheduled for %s',
36 customized_data.get('channel'), platform,
37 repr(crash_identifiers))
38 return False, None
39
40 # TODO(katesonia): Remove the default value after adding validity check to
41 # config.
42 for blacklist_marker in crash_config.fracas.get(
stgao 2016/09/13 16:37:31 At top of this file, should we add a docstring tha
Sharu Jiang 2016/09/14 20:38:38 Done.
43 'signature_blacklist_markers', []):
44 if blacklist_marker in signature:
45 logging.info('%s signature is not supported. '
46 'No analysis is scheduled for %s', blacklist_marker,
47 repr(crash_identifiers))
48 return False, None
49
50 # TODO(katesonia): Remove the default value after adding validity check to
51 # config.
52 platform_rename = crash_config.fracas.get('platform_rename', {})
53 platform = platform_rename.get(platform, platform)
54
55 # TODO(katesonia): Add clusterfuzz policy check.
56 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
57 pass
stgao 2016/09/13 16:37:31 Will this trigger a pipeline to run the analysis?
Sharu Jiang 2016/09/14 20:38:38 No, this is only for checking policy to see if ana
58
59 return True, (crash_identifiers, chrome_version, signature, client_id,
60 platform, stack_trace, customized_data)
61
62
63 def GetAnalysisForClient(crash_identifiers, client_id):
64 analysis = None
65 if client_id == CrashClient.FRACAS:
66 analysis = FracasCrashAnalysis.Get(crash_identifiers)
67 elif client_id == CrashClient.CRACAS: # pragma: no cover.
68 # TODO(katesonia): Add CracasCrashAnalysis model.
69 pass
70 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
71 # TODO(katesonia): Add ClusterfuzzCrashAnalysis model.
72 pass
73
74 return analysis
75
76
77 @ndb.transactional
78 def ResetAnalysis(analysis, crash_identifiers, chrome_version, signature,
79 client_id, platform, stack_trace, customized_data):
80 """Resets analysis to be analyzed."""
81 if not analysis:
82 # A new analysis is needed if there is no analysis.
83 if client_id == CrashClient.FRACAS:
84 analysis = FracasCrashAnalysis.Create(crash_identifiers)
85 elif client_id == CrashClient.CRACAS: # pragma: no cover.
86 # TODO(katesonia): define CracasCrashAnalysis.
87 pass
stgao 2016/09/13 16:37:31 Will this result int error later in the code below
Sharu Jiang 2016/09/14 20:38:38 Done.
88 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
89 # TODO(katesonia): define ClusterfuzzCrashAnalysis.
90 pass
91
92 analysis.Reset()
93
94 # Set common properties.
95 analysis.crashed_version = chrome_version
96 analysis.stack_trace = stack_trace
97 analysis.signature = signature
98 analysis.platform = platform
99 analysis.client_id = client_id
100
101 if client_id == CrashClient.FRACAS or client_id == CrashClient.CRACAS:
102 # Set customized properties.
103 analysis.historical_metadata = customized_data.get('historical_metadata')
104 analysis.channel = customized_data.get('channel')
105 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
106 # TODO(katesonia): Set up clusterfuzz customized data.
107 pass
108
109 # Set analysis progress properties.
110 analysis.status = analysis_status.PENDING
111 analysis.requested_time = time_util.GetUTCNow()
112
113 analysis.put()
114
115
116 def GetPublishResultFromAnalysis(analysis, crash_identifiers, client_id):
117 """Gets result to be published to client from datastore analysis."""
118 analysis_result = copy.deepcopy(analysis.result)
119
120 if (analysis.client_id == CrashClient.FRACAS or
121 analysis.client_id == CrashClient.CRACAS):
122 analysis_result['feedback_url'] = _FINDIT_FRACAS_FEEDBACK_URL_TEMPLATE % (
123 app_identity.get_default_version_hostname(), analysis.key.urlsafe())
stgao 2016/09/13 16:37:31 Should we move the hostname part to common/appengi
Sharu Jiang 2016/09/14 20:38:38 Done.
124 if analysis_result['found']:
125 for cl in analysis_result['suspected_cls']:
126 cl['confidence'] = round(cl['confidence'], 2)
127 cl.pop('reason', None)
128 elif client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
129 # TODO(katesonia): Post process clusterfuzz analysis result if needed.
130 pass
131
132 return {
133 'crash_identifiers': crash_identifiers,
134 'client_id': analysis.client_id,
135 'result': analysis_result,
136 }
137
138
139 def FindCulprit(analysis):
140 result = {'found': False}
141 tags = {'found_suspects': False,
142 'has_regression_range': False}
143
144 if (analysis.client_id == CrashClient.FRACAS or
145 analysis.client_id == CrashClient.CRACAS):
146 result, tags = findit_for_fracas.FindCulpritForChromeCrash(
147 analysis.signature, analysis.platform, analysis.stack_trace,
148 analysis.crashed_version, analysis.historical_metadata)
149 elif analysis.client_id == CrashClient.CLUSTERFUZZ: # pragma: no cover.
150 # TODO(katesonia): Implement findit_for_clusterfuzz.
151 pass
152
153 return result, tags
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698