1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-03 11:52:36 +01:00

fw/execution: Handle unresponsive targets

If a target error occurs, check whether the target is unresponsive. If
it is, attempt to hard reset it if possible, or gracefully terminate
execution if not.
This commit is contained in:
Sergei Trofimov
2018-02-28 10:24:56 +00:00
committed by Marc Bonnici
parent fdb872d9cd
commit 6fe31d6cad
4 changed files with 40 additions and 15 deletions

View File

@@ -22,7 +22,8 @@ from datetime import datetime
import wa.framework.signal as signal
from wa.framework import instrument
from wa.framework.configuration.core import Status
from wa.framework.exception import HostError, WorkloadError
from wa.framework.exception import TargetError, HostError, WorkloadError,\
TargetNotRespondingError, TimeoutError
from wa.framework.job import Job
from wa.framework.output import init_job_output
from wa.framework.output_processor import ProcessorManager
@@ -375,17 +376,18 @@ class Runner(object):
self.send(signal.RUN_INITIALIZED)
while self.context.job_queue:
try:
with signal.wrap('JOB_EXECUTION', self, self.context):
self.run_next_job(self.context)
except KeyboardInterrupt:
self.context.skip_remaining_jobs()
with signal.wrap('JOB_EXECUTION', self, self.context):
self.run_next_job(self.context)
except KeyboardInterrupt as e:
log.log_error(e, self.logger)
self.logger.info('Skipping remaining jobs.')
self.context.skip_remaining_jobs()
except Exception as e:
self.context.add_event(e.message)
if (not getattr(e, 'logged', None) and
not isinstance(e, KeyboardInterrupt)):
log.log_error(e, self.logger)
e.logged = True
message = e.message if e.message else str(e)
log.log_error(e, self.logger)
self.logger.error('Skipping remaining jobs due to "{}".'.format(e))
self.context.skip_remaining_jobs()
raise e
finally:
self.finalize_run()
@@ -429,6 +431,10 @@ class Runner(object):
if not getattr(e, 'logged', None):
log.log_error(e, self.logger)
e.logged = True
if isinstance(e, ExecutionError):
raise e
elif isinstance(e, TargetError):
context.tm.verify_target_responsive()
finally:
self.logger.info('Completing job {}'.format(job.id))
self.send(signal.JOB_COMPLETED)
@@ -467,6 +473,8 @@ class Runner(object):
if not getattr(e, 'logged', None):
log.log_error(e, self.logger)
e.logged = True
if isinstance(e, TargetError) or isinstance(e, TimeoutError):
context.tm.verify_target_responsive()
raise e
finally:
try:
@@ -474,8 +482,10 @@ class Runner(object):
job.process_output(context)
self.pm.process_job_output(context)
self.pm.export_job_output(context)
except Exception:
except Exception as e:
job.set_status(Status.PARTIAL)
if isinstance(e, TargetError) or isinstance(e, TimeoutError):
context.tm.verify_target_responsive()
raise
except KeyboardInterrupt: