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

Side by Side Diff: appengine/findit/waterfall/process_base_swarming_task_result_pipeline.py

Issue 2312413002: [Findit] Record error if swarming task completes with exit_code as 2. (Closed)
Patch Set: . Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | appengine/findit/waterfall/swarming_util.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from collections import defaultdict 5 from collections import defaultdict
6 import datetime 6 import datetime
7 import logging 7 import logging
8 import time 8 import time
9 9
10 from common.http_client_appengine import HttpClientAppengine as HttpClient 10 from common.http_client_appengine import HttpClientAppengine as HttpClient
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 task_started = False 79 task_started = False
80 task_completed = False 80 task_completed = False
81 tests_statuses = {} 81 tests_statuses = {}
82 step_name_no_platform = None 82 step_name_no_platform = None
83 83
84 while not task_completed: 84 while not task_completed:
85 # Keeps monitoring the swarming task, waits for it to complete. 85 # Keeps monitoring the swarming task, waits for it to complete.
86 data = swarming_util.GetSwarmingTaskResultById( 86 data = swarming_util.GetSwarmingTaskResultById(
87 task_id, self.HTTP_CLIENT) 87 task_id, self.HTTP_CLIENT)
88 task_state = data['state'] 88 task_state = data['state']
89 exit_code = (data['exit_code'] if
90 task_state == swarming_util.STATE_COMPLETED else None)
89 step_name_no_platform = swarming_util.GetTagValue( 91 step_name_no_platform = swarming_util.GetTagValue(
90 data.get('tags', {}), 'ref_name') 92 data.get('tags', {}), 'ref_name')
91 if task_state not in swarming_util.STATES_RUNNING: 93 if task_state not in swarming_util.STATES_RUNNING:
92 task_completed = True 94 task_completed = True
93 task = self._GetSwarmingTask(*call_args) 95 task = self._GetSwarmingTask(*call_args)
94 if task_state == swarming_util.STATE_COMPLETED: 96 print task_state == swarming_util.STATE_COMPLETED
97 print exit_code
Sharu Jiang 2016/09/08 21:41:54 Are these 2 prints intended?
chanli 2016/09/08 22:07:21 Done.
98 if (task_state == swarming_util.STATE_COMPLETED and
99 int(exit_code) != swarming_util.TASK_FAILED):
95 outputs_ref = data.get('outputs_ref') 100 outputs_ref = data.get('outputs_ref')
96 output_json = swarming_util.GetSwarmingTaskFailureLog( 101 output_json = swarming_util.GetSwarmingTaskFailureLog(
97 outputs_ref, self.HTTP_CLIENT) 102 outputs_ref, self.HTTP_CLIENT)
98 tests_statuses = self._CheckTestsRunStatuses( 103 tests_statuses = self._CheckTestsRunStatuses(
99 output_json, *call_args) 104 output_json, *call_args)
100 task.status = analysis_status.COMPLETED 105 task.status = analysis_status.COMPLETED
101 task.tests_statuses = tests_statuses 106 task.tests_statuses = tests_statuses
102 else: 107 else:
103 task.status = analysis_status.ERROR 108 task.status = analysis_status.ERROR
104 logging.error('Swarming task stopped with status: %s' % ( 109 logging_str = 'Swarming task stopped with status: %s' % task_state
lijeffrey 2016/09/08 22:14:05 nit: rename this error_str, since it's used in the
105 task_state)) 110 if exit_code:
lijeffrey 2016/09/08 22:14:05 is it possible for exit_code to be 0 here instead
111 logging_str += ' and exit_code: %s - %s' % (
112 exit_code, swarming_util.EXIT_CODE_DESCRIPTIONS[int(exit_code)])
lijeffrey 2016/09/08 22:14:05 nit: since int(exit_code) is now being used in 2 p
113 logging.error(logging_str)
114
106 priority_str = swarming_util.GetTagValue( 115 priority_str = swarming_util.GetTagValue(
107 data.get('tags', {}), 'priority') 116 data.get('tags', {}), 'priority')
108 if priority_str: 117 if priority_str:
109 task.parameters['priority'] = int(priority_str) 118 task.parameters['priority'] = int(priority_str)
110 task.put() 119 task.put()
111 else: # pragma: no cover 120 else: # pragma: no cover
112 if task_state == 'RUNNING' and not task_started: 121 if task_state == 'RUNNING' and not task_started:
113 # swarming task just starts, update status. 122 # swarming task just starts, update status.
114 task_started = True 123 task_started = True
115 task = self._GetSwarmingTask(*call_args) 124 task = self._GetSwarmingTask(*call_args)
116 task.status = analysis_status.RUNNING 125 task.status = analysis_status.RUNNING
117 task.put() 126 task.put()
118 time.sleep(server_query_interval_seconds) 127 time.sleep(server_query_interval_seconds)
119 if time.time() > deadline: 128 if time.time() > deadline:
120 # Updates status as ERROR. 129 # Updates status as ERROR.
121 task = self._GetSwarmingTask(*call_args) 130 task = self._GetSwarmingTask(*call_args)
122 task.status = analysis_status.ERROR 131 task.status = analysis_status.ERROR
123 task.put() 132 task.put()
124 logging.error('Swarming task timed out after %d hours.' % timeout_hours) 133 logging.error('Swarming task timed out after %d hours.' % timeout_hours)
125 break # Stops the loop and return. 134 break # Stops the loop and return.
126 # Update swarming task metadate. 135 # Update swarming task metadate.
127 task = self._GetSwarmingTask(*call_args) 136 task = self._GetSwarmingTask(*call_args)
128 task.created_time = self._ConvertDateTime(data.get('created_ts')) 137 task.created_time = self._ConvertDateTime(data.get('created_ts'))
129 task.started_time = self._ConvertDateTime(data.get('started_ts')) 138 task.started_time = self._ConvertDateTime(data.get('started_ts'))
130 task.completed_time = self._ConvertDateTime(data.get('completed_ts')) 139 task.completed_time = self._ConvertDateTime(data.get('completed_ts'))
131 task.put() 140 task.put()
132 141
133 return step_name, step_name_no_platform 142 return step_name, step_name_no_platform
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/waterfall/swarming_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698