Add a new class of chaos monkey errors after the inner code has run. Lower the overall error rate to reduce traffic.

This commit is contained in:
Ian Gulliver
2014-05-27 16:58:20 -07:00
parent 4427af1505
commit 3b18676f59
2 changed files with 10 additions and 2 deletions

View File

@@ -6,4 +6,4 @@ NAMESPACE = 'cosmopolite'
CHANNEL_DURATION_SECONDS = 60 * 60 * 2 # 2 hours CHANNEL_DURATION_SECONDS = 60 * 60 * 2 # 2 hours
# Probabilities # Probabilities
CHAOS_PROBABILITY = 0.50 CHAOS_PROBABILITY = 0.05

View File

@@ -52,7 +52,15 @@ def chaos_monkey(handler):
self.response.headers['Retry-After'] = '0' self.response.headers['Retry-After'] = '0'
self.error(503) self.error(503)
return return
return handler(self)
ret = handler(self)
if random.random() < config.CHAOS_PROBABILITY:
self.response.headers['Retry-After'] = '0'
self.error(503)
return
return ret
return IntroduceFailures return IntroduceFailures