Merge pull request #233 from mozilla/remove-unclassified-count-code

bug 1075166 - remove all code regarding unclassified failures
This commit is contained in:
Mauro Doglio 2014-10-06 15:08:57 +01:00
Родитель 43e47cd7d1 895ad7bc3c
Коммит 7b1bc30228
6 изменённых файлов: 0 добавлений и 187 удалений

Просмотреть файл

@ -109,19 +109,3 @@ class JobClassificationPublisher(EventsPublisher):
message,
"events.{0}.job_classification".format(branch)
)
class UnclassifiedFailureCountPublisher(EventsPublisher):
def publish(self, branch, count, count_excluded):
message = {
"count": count,
"count_excluded": count_excluded,
"event": "unclassified_failure_count",
"branch": branch
}
super(UnclassifiedFailureCountPublisher, self).publish(
message,
"events.{0}.unclassified_failure_count".format(branch)
)

Просмотреть файл

@ -155,9 +155,6 @@ class JobsModel(TreeherderModelBase):
# 6 months in seconds
DATA_CYCLE_INTERVAL = 15552000
# last 24 hours in seconds
UNCLASSIFIED_FAILURE_RANGE = 86400
@classmethod
def create(cls, project, host=None):
"""
@ -249,83 +246,6 @@ class JobsModel(TreeherderModelBase):
)
return data
def get_unclassified_failure_count_excluded(self):
"""
Get the count of unclassified failed jobs that are being hidden/excluded
this value can be subtracted from ``get_unclassified_failure_count``
to get the number that should be shown to the user when exclusions are
active.
"""
flat_exclusions = ExclusionProfile.objects.filter(
is_default=1).values("flat_exclusion")
count = 0
try:
condition, values_list = utils.where_wolf(self.project, flat_exclusions)
repl = [
self.refdata_model.get_db_name(),
"'" + "','".join(self.FAILED_RESULTS) + "'",
condition
]
placeholders = [
utils.get_now_timestamp() - self.UNCLASSIFIED_FAILURE_RANGE,
]
placeholders.extend(values_list)
proc = "jobs.selects.get_unclassified_failure_count_excluded"
data = self.get_jobs_dhub().execute(
proc=proc,
replace=repl,
placeholders=placeholders,
debug_show=self.DEBUG,
)
if len(data):
count = data[0]["count_excluded"]
cache.set(
"{0}:unclassified_failure_count_excluded".format(self.project),
count)
except Exception as ex:
# there may be no exclusions for this repo/project
# pass and fall through to the zero count response.
pass
return count
def get_unclassified_failure_count(self):
"""
Get the count of unclassified failed jobs ignoring exclusions
"""
repl = ["'" + "','".join(self.FAILED_RESULTS) + "'"]
placeholders = [utils.get_now_timestamp() -
self.UNCLASSIFIED_FAILURE_RANGE]
proc = "jobs.selects.get_unclassified_failure_count"
data = self.get_jobs_dhub().execute(
proc=proc,
replace=repl,
placeholders=placeholders,
debug_show=self.DEBUG,
)
count = 0
if len(data):
count = data[0]["count"]
cache.set(
"{0}:unclassified_failure_count".format(self.project),
count
)
return count
def _process_conditions(self, conditions, allowed_fields=None):
"""Transform a list of conditions into a list of placeholders and
replacement strings to feed a datahub.execute statement."""

Просмотреть файл

@ -203,27 +203,6 @@
"description": "Deletes data from the objectstore and jobs databases that's greater than six months old"
}
},
{
"pk": 9,
"model": "djcelery.periodictask",
"fields": {
"task": "unclassified-failure-count",
"name": "unclassified-failure-count",
"exchange": null,
"last_run_at": null,
"args": "[]",
"enabled": true,
"routing_key": null,
"crontab": null,
"interval": 2,
"queue": null,
"total_run_count": 0,
"expires": null,
"kwargs": "{}",
"date_changed": "2014-04-24T16:22:39",
"description": "Broadcasts the count of unclassified job failures per repository"
}
},
{
"pk": 10,
"model": "djcelery.periodictask",

Просмотреть файл

@ -481,36 +481,6 @@
"host":"master_host"
},
"get_unclassified_failure_count":{
"sql":"SELECT count(j.id) as count FROM job as j
LEFT JOIN result_set as rs
ON rs.id = j.result_set_id
WHERE j.failure_classification_id=1
AND j.result IN (REP0)
AND rs.push_timestamp > ?",
"host":"read_host"
},
"get_unclassified_failure_count_excluded":{
"sql":"SELECT count(j.id) as count_excluded FROM job as j
LEFT JOIN REP0.machine_platform as mp
ON j.machine_platform_id = mp.id
LEFT JOIN REP0.job_type as jt
ON j.job_type_id = jt.id
LEFT JOIN REP0.option_collection as oc
ON j.option_collection_hash = oc.option_collection_hash
LEFT JOIN REP0.option as opt
ON oc.option_id = opt.id
LEFT JOIN result_set as rs
ON rs.id = j.result_set_id
WHERE j.failure_classification_id=1
AND j.result in (REP1)
AND rs.push_timestamp > ?
REP2",
"host":"read_host"
},
"get_incomplete_job_guids": {
"sql": "SELECT j.job_guid, j.result_set_id, rs.push_timestamp as result_set_push_timestamp
FROM job as j

Просмотреть файл

@ -3,7 +3,6 @@ from django.conf import settings
from treeherder.model.derived import JobsModel
from treeherder.model.models import Datasource, Repository
from treeherder.events.publisher import UnclassifiedFailureCountPublisher
@task(name='process-objects')
def process_objects(limit=None):
@ -54,24 +53,6 @@ def cycle_data(max_iterations=50, debug=False):
jm.disconnect()
@task(name='unclassified-failure-count', rate_limit='60/h')
def unclassified_failure_count(projects=None):
if not projects:
projects = Repository.objects.all().values_list('name', flat=True)
unclassified_failure_publisher = UnclassifiedFailureCountPublisher(settings.BROKER_URL)
for project in projects:
jm = JobsModel(project)
count = jm.get_unclassified_failure_count()
count_excluded = jm.get_unclassified_failure_count_excluded()
unclassified_failure_publisher.publish(project, count, count_excluded)
jm.disconnect()
unclassified_failure_publisher.disconnect()
@task(name='calculate-eta', rate_limit='1/h')
def calculate_eta(sample_window_seconds=21600, debug=False):

Просмотреть файл

@ -4,8 +4,6 @@ from rest_framework.decorators import action, link
from rest_framework.reverse import reverse
from rest_framework.permissions import IsAuthenticated
from django.core.cache import cache
from treeherder.webapp.api.utils import (UrlQueryFilter, with_jobs,
oauth_required, get_option)
@ -16,25 +14,6 @@ class JobsViewSet(viewsets.ViewSet):
"""
@link()
@with_jobs
def unclassified_failure_count(self, request, project, jm, pk=None):
"""
GET method for revisions of a resultset
"""
count = cache.get(
"{0}:unclassified_failure_count".format(project)
)
count_excluded = cache.get(
"{0}:unclassified_failure_count_excluded".format(project)
)
return Response({
"repository": project,
"count": count or 0,
"count_excluded": count_excluded or 0
})
@with_jobs
def retrieve(self, request, project, jm, pk=None):
"""