From ee4d206745b5e9069453aef610aef3fe0a9901c7 Mon Sep 17 00:00:00 2001 From: Daniel Goldberg Date: Sun, 15 Oct 2017 19:32:19 +0300 Subject: [PATCH] Simplified generic attack logic --- chaos_monkey/monkey.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chaos_monkey/monkey.py b/chaos_monkey/monkey.py index ae558a7a0..79012dc39 100644 --- a/chaos_monkey/monkey.py +++ b/chaos_monkey/monkey.py @@ -160,20 +160,20 @@ class ChaosMonkey(object): LOG.info("Trying to exploit %r with exploiter %s...", machine, exploiter.__class__.__name__) + result = False try: - if exploiter.exploit_host(): + result = exploiter.exploit_host() + if result: successful_exploiter = exploiter - exploiter.send_exploit_telemetry(True) break else: LOG.info("Failed exploiting %r with exploiter %s", machine, exploiter.__class__.__name__) - exploiter.send_exploit_telemetry(False) except Exception as exc: LOG.exception("Exception while attacking %s using %s: %s", machine, exploiter.__class__.__name__, exc) - exploiter.send_exploit_telemetry(False) - continue + finally: + exploiter.send_exploit_telemetry(result) if successful_exploiter: self._exploited_machines.add(machine)