Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
Don't reconnect on event_stream_detached.
Browse files Browse the repository at this point in the history
We should also randomize the reconnect delay on exceptions.
  • Loading branch information
brndnmtthws committed Mar 2, 2016
1 parent 527083d commit 0cb49d8
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions marathon_lb.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import dateutil.parser
import math
import threading
import random


class ConfigTemplater(object):
Expand Down Expand Up @@ -1460,10 +1461,6 @@ def process_sse_events(marathon, config_file, groups,
data = json.loads(real_event_data)
logger.info(
"received event of type {0}".format(data['eventType']))
if data['eventType'] == 'event_stream_detached':
# Need to force reload and re-attach to stream
processor.reset_from_tasks()
return
processor.handle_event(data)
else:
logger.info("skipping empty message")
Expand Down Expand Up @@ -1527,7 +1524,7 @@ def process_sse_events(marathon, config_file, groups,
except:
logger.exception("Caught exception")
logger.error("Reconnecting...")
time.sleep(1)
time.sleep(random.random() * 3)
else:
# Generate base config
regenerate_config(get_apps(marathon), args.haproxy_config, args.group,
Expand Down

0 comments on commit 0cb49d8

Please sign in to comment.