Merge lp:~sseman/juju-chaos-monkey/run-once-and-reset into lp:juju-chaos-monkey

Proposed by Seman
Status: Merged
Merged at revision: 20
Proposed branch: lp:~sseman/juju-chaos-monkey/run-once-and-reset
Merge into: lp:juju-chaos-monkey
Diff against target: 34 lines (+8/-3)
1 file modified
runner.py (+8/-3)
To merge this branch: bzr merge lp:~sseman/juju-chaos-monkey/run-once-and-reset
Reviewer Review Type Date Requested Status
John George (community) Approve
Review via email: mp+261300@code.launchpad.net

Description of the change

Added a code to terminate Chaos Monkey after a reboot if restart and run-once are selected.

To post a comment you must log in.
Revision history for this message
John George (jog) wrote :

Thank you.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'runner.py'
2--- runner.py 2015-06-05 00:53:49 +0000
3+++ runner.py 2015-06-05 23:09:52 +0000
4@@ -104,15 +104,16 @@
5 if chaos.disable:
6 chaos.disable()
7
8- def cleanup(self):
9+ def cleanup(self, restart=False):
10 if self.lock_file:
11 try:
12 os.unlink(self.lock_file)
13 except OSError as e:
14 if e.errno != errno.ENOENT:
15 raise
16- logging.warning('Lock file not found: {}'.format(
17- self.lock_file))
18+ if not restart:
19+ logging.warning('Lock file not found: {}'.format(
20+ self.lock_file))
21 logging.info('Chaos Monkey stopped.\n')
22
23 def filter_commands(self, include_group=None, exclude_group=None,
24@@ -260,6 +261,10 @@
25 msg = 'started' if not args.restart else 'restarted after a reboot'
26 logging.info('Chaos Monkey {} in {}'.format(msg, args.path))
27 logging.debug('Dry run is set to {}'.format(args.dry_run))
28+ if args.run_once and args.restart:
29+ runner.cleanup(restart=True)
30+ sys.exit(0)
31+
32 runner.acquire_lock(restart=args.restart)
33 try:
34 runner.random_chaos(

Subscribers

People subscribed via source and target branches