Skip to content

Commit 7c5b35c

Browse files
committed
Added switch to time travel to runner.py
1 parent ca9e618 commit 7c5b35c

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

runner.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def __init__(self,
8989
name, uri, uri_type, filename='usage_scenario.yml', branch=None,
9090
debug_mode=False, allow_unsafe=False, no_file_cleanup=False, skip_system_checks=False,
9191
skip_unsafe=False, verbose_provider_boot=False, full_docker_prune=False,
92-
dev_no_sleeps=False, dev_no_build=False, dev_no_metrics=False, docker_prune=False, job_id=None):
92+
dev_no_sleeps=False, dev_no_build=False, dev_no_metrics=False,
93+
dev_flow_timetravel=False, docker_prune=False, job_id=None):
9394

9495
if skip_unsafe is True and allow_unsafe is True:
9596
raise RuntimeError('Cannot specify both --skip-unsafe and --allow-unsafe')
@@ -107,6 +108,7 @@ def __init__(self,
107108
self._dev_no_sleeps = dev_no_sleeps
108109
self._dev_no_build = dev_no_build
109110
self._dev_no_metrics = dev_no_metrics
111+
self._dev_flow_timetravel = dev_flow_timetravel
110112
self._uri = uri
111113
self._uri_type = uri_type
112114
self._original_filename = filename
@@ -1150,7 +1152,12 @@ def run_flows(self):
11501152
self.__ps_to_read += ps_to_read_tmp # will otherwise be discarded, bc they confuse execption handling
11511153
self.check_process_returncodes()
11521154
flow_id += 1
1155+
1156+
# pylint: disable=broad-exception-caught
11531157
except BaseException as exc:
1158+
if self._dev_flow_timetravel: # Exception handling only if explicitely wanted
1159+
raise exc
1160+
11541161
print('Exception occured: ', exc)
11551162
print(TerminalColors.OKCYAN, '\nWhat do you want to do?\n1 -- Restart current flow\n2 -- Restart all flows\n3 -- Reload containers and restart flows\n0 / CTRL+C -- Abort', TerminalColors.ENDC)
11561163
value = sys.stdin.readline().strip()
@@ -1161,11 +1168,13 @@ def run_flows(self):
11611168
process_helpers.kill_ps(ps_to_kill_tmp)
11621169

11631170
if value == '0':
1164-
raise KeyboardInterrupt("Manual abort")
1171+
raise KeyboardInterrupt("Manual abort") from exc
11651172
if value == '1':
1166-
self.__phases.pop(flow['name'])
1173+
self.__phases.popitem(last=True)
11671174
if value == '2':
1168-
self.__phases = OrderedDict()
1175+
for _ in range(0,flow_id+1):
1176+
self.__phases.popitem(last=True)
1177+
flow_id = 0
11691178
if value == '3':
11701179
self.cleanup(inline=True)
11711180
self.setup_networks()
@@ -1511,6 +1520,7 @@ def run(self):
15111520
parser.add_argument('--verbose-provider-boot', action='store_true', help='Boot metric providers gradually')
15121521
parser.add_argument('--full-docker-prune', action='store_true', help='Stop and remove all containers, build caches, volumes and images on the system')
15131522
parser.add_argument('--docker-prune', action='store_true', help='Prune all unassociated build caches, networks volumes and stopped containers on the system')
1523+
parser.add_argument('--dev-flow-timetravel', action='store_true', help='Allows to repeat a failed flow or timetravel to beginning of flows or restart services.')
15141524
parser.add_argument('--dev-no-metrics', action='store_true', help='Skips loading the metric providers. Runs will be faster, but you will have no metric')
15151525
parser.add_argument('--dev-no-sleeps', action='store_true', help='Removes all sleeps. Resulting measurement data will be skewed.')
15161526
parser.add_argument('--dev-no-build', action='store_true', help='Checks if a container images are already in the local cache and will then not build it. Also doesn\'t clear the images after a run. Please note that skipping builds only works the second time you make a run.')
@@ -1574,7 +1584,8 @@ def run(self):
15741584
no_file_cleanup=args.no_file_cleanup, skip_system_checks=args.skip_system_checks,
15751585
skip_unsafe=args.skip_unsafe,verbose_provider_boot=args.verbose_provider_boot,
15761586
full_docker_prune=args.full_docker_prune, dev_no_sleeps=args.dev_no_sleeps,
1577-
dev_no_build=args.dev_no_build, dev_no_metrics=args.dev_no_metrics, docker_prune=args.docker_prune)
1587+
dev_no_build=args.dev_no_build, dev_no_metrics=args.dev_no_metrics,
1588+
dev_flow_timetravel=args.dev_flow_timetravel, docker_prune=args.docker_prune)
15781589

15791590
# Using a very broad exception makes sense in this case as we have excepted all the specific ones before
15801591
#pylint: disable=broad-except

0 commit comments

Comments
 (0)