1
1
import datetime
2
2
3
- from treeherder .model .models import Group , GroupStatus , Job , JobLog , Push
3
+ from treeherder .model .models import Group , GroupStatus , Job , Push
4
4
5
5
6
6
def _check_and_mark_infra (current_job , job_ids , push_ids ):
@@ -17,22 +17,23 @@ def _check_and_mark_infra(current_job, job_ids, push_ids):
17
17
# look for all jobs in pushids matching current_job.job_type.name
18
18
# if older are failing for "infra", then ensure same job is passing
19
19
# if so mark as intermittent
20
- extra_jobs = JobLog .objects .filter (
21
- job__push__id__range = (push_ids [- 1 ], push_ids [0 ]),
22
- job__push__repository__id = current_job .repository .id ,
23
- job__job_type__name = current_job .job_type .name ,
24
- job__failure_classification_id__in = [1 , 6 ],
25
- status__in = (1 , 2 , 3 ), # ignore pending
26
- job__result__in = [
20
+ extra_jobs = Job .objects .filter (
21
+ push__id__range = (push_ids [- 1 ], push_ids [0 ]),
22
+ repository__id = current_job .repository .id ,
23
+ job_type__name = current_job .job_type .name ,
24
+ failure_classification_id__in = [1 , 6 ],
25
+ job_log__status__in = [1 , 3 ], # ignore pending, failed
26
+ state = "completed" , # ignore running/pending
27
+ result__in = [
27
28
"busted" ,
28
29
"testfailed" ,
29
30
"exception" ,
30
31
"success" ,
31
32
], # primarily ignore retry/usercancel
32
33
).values (
33
- "job__id " ,
34
- "job__result " ,
35
- "job__failure_classification_id " ,
34
+ "id " ,
35
+ "result " ,
36
+ "failure_classification_id " ,
36
37
)
37
38
38
39
if len (extra_jobs ) == 0 :
@@ -43,7 +44,7 @@ def _check_and_mark_infra(current_job, job_ids, push_ids):
43
44
# jobs without groups (like marionette) will still get tallied properly here
44
45
extra_failed = []
45
46
for job in extra_jobs :
46
- if job ["job__id " ] not in job_ids and job ["job__result " ] != "success" :
47
+ if job ["id " ] not in job_ids and job ["result " ] != "success" :
47
48
extra_failed .append (job )
48
49
49
50
# look for failure rate > 50% and exit early
@@ -54,8 +55,8 @@ def _check_and_mark_infra(current_job, job_ids, push_ids):
54
55
# theoretically there could be many jobs here
55
56
# mark extra_jobs as `intermittent_needs_classification`
56
57
for job in extra_failed :
57
- if job ["job__failure_classification_id " ] not in [4 , 8 ]:
58
- Job .objects .filter (id = job ["job__id " ]).update (failure_classification_id = 8 )
58
+ if job ["failure_classification_id " ] not in [4 , 8 ]:
59
+ Job .objects .filter (id = job ["id " ]).update (failure_classification_id = 8 )
59
60
60
61
61
62
def check_and_mark_intermittent (job_id ):
0 commit comments