@@ -21,7 +21,7 @@ def _check_and_mark_infra(current_job, job_ids, push_ids):
21
21
push__id__range = (push_ids [- 1 ], push_ids [0 ]),
22
22
repository__id = current_job .repository .id ,
23
23
job_type__name = current_job .job_type .name ,
24
- failure_classification_id__in = [1 , 6 ],
24
+ failure_classification_id__in = [1 , 6 , 8 ],
25
25
job_log__status__in = [1 , 3 ], # ignore pending, failed
26
26
state = "completed" , # ignore running/pending
27
27
result__in = [
@@ -36,7 +36,8 @@ def _check_and_mark_infra(current_job, job_ids, push_ids):
36
36
"failure_classification_id" ,
37
37
)
38
38
39
- if len (extra_jobs ) == 0 :
39
+ # ignore previous classified, we are looking for NEW extra jobs
40
+ if len ([ej for ej in extra_jobs if ej ["failure_classification_id" ] != 8 ]) == 0 :
40
41
return
41
42
42
43
# ensure 50% 'success' rate
@@ -49,6 +50,10 @@ def _check_and_mark_infra(current_job, job_ids, push_ids):
49
50
50
51
# look for failure rate > 50% and exit early
51
52
if len (extra_failed ) / len (extra_jobs ) > 0.5 :
53
+ # as failure rate > 50%, if any jobs are fc_id=8 classify as fc_id=1
54
+ for job in extra_failed :
55
+ if job ["failure_classification_id" ] == 8 :
56
+ Job .objects .filter (id = job ["id" ]).update (failure_classification_id = 1 )
52
57
return
53
58
54
59
# any extra_jobs will be failures without groups (infra/timeout/etc.)
@@ -117,6 +122,7 @@ def check_and_mark_intermittent(job_id):
117
122
"group_result__status" ,
118
123
"job_logs__job__job_type__name" ,
119
124
"job_logs__job__push__id" ,
125
+ "job_logs__job__failure_classification__id" ,
120
126
)
121
127
.order_by ("-job_logs__job__push__id" )
122
128
)
@@ -127,6 +133,7 @@ def check_and_mark_intermittent(job_id):
127
133
return _check_and_mark_infra (current_job , distinct_job_ids , ids )
128
134
129
135
mappings = {}
136
+ job_classifications = {}
130
137
for item in all_groups :
131
138
jobname = item ["job_logs__job__job_type__name" ].strip ("-cf" )
132
139
try :
@@ -139,6 +146,12 @@ def check_and_mark_intermittent(job_id):
139
146
# we have a variant
140
147
continue
141
148
149
+ # store job:fc_id so we can reference what needs changed
150
+ if item ["job_logs__job__id" ] not in job_classifications :
151
+ job_classifications [item ["job_logs__job__id" ]] = item [
152
+ "job_logs__job__failure_classification__id"
153
+ ]
154
+
142
155
if item ["job_logs__job__push__id" ] not in mappings :
143
156
mappings [item ["job_logs__job__push__id" ]] = {"groups" : {}, "jobs" : {}}
144
157
groups = mappings [item ["job_logs__job__push__id" ]]["groups" ]
@@ -186,6 +199,8 @@ def check_and_mark_intermittent(job_id):
186
199
187
200
# all changed_groups need to be evaluated on previous 'failed' jobs to ensure all groups in that task are 'passing'
188
201
for id in mappings .keys ():
202
+ jobs_to_classify = [] # mark as fcid=8 (known intermittent)
203
+ jobs_to_unclassify = [] # previously parked as fcid=8, new failing data, now fcid=1
189
204
for job in mappings [id ]["jobs" ]:
190
205
all_green = True
191
206
current_all_green = True
@@ -205,11 +220,23 @@ def check_and_mark_intermittent(job_id):
205
220
if (id == current_job .push .id and current_all_green ) or (
206
221
id != current_job .push .id and len (ids ) > 1 and all_green
207
222
):
208
- target_job = Job .objects .filter (id = job )
223
+ jobs_to_classify .append (job )
224
+ elif job_classifications [job ] == 8 :
225
+ jobs_to_unclassify .append (job )
226
+
227
+ # TODO: consider job.result=(busted, exception)
228
+ for job in jobs_to_classify :
229
+ target_job = Job .objects .filter (
230
+ id = job , result = "testfailed" , failure_classification_id__in = [1 , 6 ]
231
+ )
232
+ if target_job :
233
+ target_job .update (failure_classification_id = 8 )
209
234
210
- if target_job [0 ].result != "success" and target_job [
211
- 0
212
- ].failure_classification_id not in [4 , 8 ]:
213
- target_job .update (failure_classification_id = 8 )
235
+ for job in jobs_to_unclassify :
236
+ target_job = Job .objects .filter (
237
+ id = job , result = "testfailed" , failure_classification_id = 8
238
+ )
239
+ if target_job :
240
+ target_job .update (failure_classification_id = 1 )
214
241
215
242
return _check_and_mark_infra (current_job , distinct_job_ids , ids )
0 commit comments