Skip to content

Commit 870bbb1

Browse files
committed
runtime/lava: in get_log_parser dont crash if log is missing
Signed-off-by: Denys Fedoryshchenko <[email protected]>
1 parent 1ce1dd2 commit 870bbb1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

kernelci/runtime/lava.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ def is_infra_error(self):
121121
def _get_job_failure_metadata(self):
122122
"""Get failed lava job metadata fields such as error type and
123123
error message"""
124-
lava_yaml = self._data['results']['lava']
124+
lava_yaml = self._data['results'].get('lava')
125+
if not lava_yaml:
126+
return None
125127
lava = yaml.safe_load(lava_yaml)
126128
stages = {stage['name']: stage for stage in lava}
127129
job_meta = stages.get('job', {}).get('metadata')
@@ -250,6 +252,8 @@ def get_hierarchy(self, results, job_node):
250252
job_node['data']['error_msg'] = job_meta.get('error_msg')
251253
else:
252254
print(f"Job failure metadata not found for node: {job_node['id']}")
255+
job_node['data']['error_code'] = "Infrastructure"
256+
job_node['data']['error_msg'] = "Unknown infrastructure error"
253257

254258
child_nodes = self._get_results_hierarchy(results)
255259

@@ -280,7 +284,10 @@ def get_hierarchy(self, results, job_node):
280284

281285
def get_log_parser(self):
282286
"""Get a LogParser object from the callback data"""
283-
return LogParser(self._data['log'])
287+
log = self._data.get('log')
288+
if not log:
289+
return None
290+
return LogParser(log)
284291

285292
def to_file(self, filename):
286293
"""Write the callback data to a JSON file"""

0 commit comments

Comments
 (0)