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

Unified Diff: appengine/findit/handlers/crash/fracas_crash.py

Issue 1852383002: [Findit] Integrate with Fracas through Pub/Sub. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Just rebase. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/findit/handlers/crash/crash_config.py ('k') | appengine/findit/handlers/crash/test/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/handlers/crash/fracas_crash.py
diff --git a/appengine/findit/handlers/crash/fracas_crash.py b/appengine/findit/handlers/crash/fracas_crash.py
new file mode 100644
index 0000000000000000000000000000000000000000..5112bfcc940670a40cb8e4608a9641c1a2fc51d0
--- /dev/null
+++ b/appengine/findit/handlers/crash/fracas_crash.py
@@ -0,0 +1,56 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import base64
+import json
+import logging
+
+from common import constants
+from common.base_handler import BaseHandler
+from common.base_handler import Permission
+from crash import fracas_crash_pipeline
+from model.crash.crash_config import CrashConfig
+
+
+FRACAS_ANALYSIS_QUEUE = 'fracas-crash-queue'
+
+
+class FracasCrash(BaseHandler):
+ PERMISSION_LEVEL = Permission.ANYONE
+
+ def HandlePost(self):
+ """Handles push delivery from Pub/Sub for crash data.
+
+ The crash data should be in the following json format:
+ {
+ 'channel': 'canary',
+ 'platform': 'win',
+ 'signature': 'namesapce1:namespace2:class_name:func_name',
+ 'stack_trace': 'frame1\nframe2\nframe3',
+ 'chrome_version': '50.0.2500.0',
+ 'versions_to_cpm': {
+ '50.0.2500.0': 1.2,
+ '50.0.2499.0': 1.0,
+ },
+ }
+ """
+ token = self.request.get('token', '').strip()
+ crash_config = CrashConfig.Get()
+ if token != crash_config.fracas.get('crash_data_push_token'):
+ logging.warning('Unauthorized access.')
+ return self.CreateError(
+ 'Unauthorized access: invalid token "%s"' % token, 403)
+
+ received_message = json.loads(self.request.body)
+ pubsub_message = received_message['message']
+ crash_data = json.loads(base64.b64decode(pubsub_message['data']))
+
+ logging.info('Processing message %s from subscription %s.',
+ pubsub_message['message_id'], received_message['subscription'])
+
+ fracas_crash_pipeline.ScheduleNewAnalysisForCrash(
+ crash_data['channel'], crash_data['platform'], crash_data['signature'],
+ crash_data['stack_trace'], crash_data['chrome_version'],
+ crash_data['versions_to_cpm'],
+ queue_name=constants.CRASH_ANALYSIS_FRACAS_QUEUE)
« no previous file with comments | « appengine/findit/handlers/crash/crash_config.py ('k') | appengine/findit/handlers/crash/test/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698