Skip to content

Instantly share code, notes, and snippets.

@evandandrea
Created February 6, 2013 15:45
Show Gist options
  • Save evandandrea/4723409 to your computer and use it in GitHub Desktop.
Save evandandrea/4723409 to your computer and use it in GitHub Desktop.
=== modified file 'schema.py'
--- schema.py 2012-12-05 15:38:38 +0000
+++ schema.py 2013-02-05 21:02:18 +0000
@@ -63,6 +63,9 @@
if 'BadRequest' not in cfs:
workaround_1779(mgr.create_column_family, keyspace, 'BadRequest',
default_validation_class=CounterColumnType())
+ if 'BucketSystems' not in cfs:
+ workaround_1779(mgr.create_column_family, keyspace, 'BucketSystems',
+ default_validation_class=UTF8_TYPE)
finally:
mgr.close()
=== modified file 'submit.wsgi'
--- submit.wsgi 2013-01-16 18:07:15 +0000
+++ submit.wsgi 2013-02-04 22:07:25 +0000
@@ -121,6 +121,7 @@
package, version = utils.split_package_and_version(package)
src_package, src_version = utils.split_package_and_version(src_package)
fields = utils.get_fields_for_bucket_counters(problem_type, release, package, version)
+ # user_token is a misnomer as it is really system specific
if user_token:
data['SystemIdentifier'] = user_token
oopses.insert_dict(oops_config, oops_id, data, user_token, fields)
=== modified file 'utils.py'
--- utils.py 2012-11-30 10:38:54 +0000
+++ utils.py 2013-02-06 15:25:43 +0000
@@ -1,10 +1,32 @@
from oops import Config
from oops_wsgi import install_hooks, make_app
from oops_datedir_repo import DateDirRepo, serializer_rfc822
+from pycassa.cassandra.ttypes import NotFoundException
from oopsrepository import oopses
import apt
import os
+import pycassa
+
+configuration = None
+try:
+ import local_config as configuration
+except ImportError:
+ pass
+if not configuration:
+ import configuration
+
+import metrics
+class FailureListener(pycassa.pool.PoolListener):
+ def connection_failed(self, dic):
+ name = 'cassandra_connection_failures'
+ metrics.get_metrics().increment(name)
+
+creds = {'username': configuration.cassandra_username,
+ 'password': configuration.cassandra_password}
+pool = pycassa.ConnectionPool(configuration.cassandra_keyspace,
+ configuration.cassandra_hosts,
+ listeners=[FailureListener()], credentials=creds)
def get_fields_for_bucket_counters(problem_type, release, package, version):
fields = []
@@ -39,10 +61,13 @@
return (package, version)
def bucket(oops_config, oops_id, crash_signature, report_dict):
+ bucketversions_cf = pycassa.ColumnFamily(pool, 'BucketVersions')
+ bucketsystems_cf = pycassa.ColumnFamily(pool, 'BucketSystems')
release = report_dict.get('DistroRelease', '')
package = report_dict.get('Package', '')
problem_type = report_dict.get('ProblemType', '')
dependencies = report_dict.get('Dependencies', '')
+ system_uuid = report_dict.get('SystemIdentifier', '')
if '[origin:' in package or '[origin:' in dependencies:
# This package came from a third-party source. We do not want to show
# its version as the Last Seen field on the most common problems table,
@@ -56,6 +81,22 @@
package, version = split_package_and_version(package)
fields = get_fields_for_bucket_counters(problem_type, release, package, version)
+ try:
+ bucket_versions = bucketversions_cf.get(crash_signature)
+ first_version, version_count = sorted(bucket_versions.iteritems(),
+ cmp=apt.apt_pkg.version_compare, key=lambda t: t[0])[0]
+ except NotFoundException:
+ # it doesn't exist in bucketversions so we want to create it
+ first_version = version
+ version_count = 0
+ # if version count is high it must have affected a lot of systems right?
+ if version == first_version and version_count < 8:
+ try:
+ systems = bucketsystems_cf.get(crash_signature)
+ if system_uuid not in systems:
+ bucketsystems_cf.insert(crash_signature, {system_uuid: ''})
+ except NotFoundException:
+ bucketsystems_cf.insert(crash_signature, {system_uuid: ''})
oopses.bucket(oops_config, oops_id, crash_signature, fields)
if (package and version) and not third_party:
oopses.update_bucket_metadata(oops_config, crash_signature, package,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment