From 8cf5fa3e4788becd2c5d673d00a6a1dfa4e8b5a6 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 3 Mar 2014 10:12:03 -0600 Subject: [PATCH] Adding a wait loop to ec2_elb for the initial lb state when registering Fixes #5305 --- cloud/ec2_elb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cloud/ec2_elb b/cloud/ec2_elb index ebd90aeda82..c6c61fd199b 100644 --- a/cloud/ec2_elb +++ b/cloud/ec2_elb @@ -157,7 +157,17 @@ class ElbManager: to report the instance in-service""" for lb in self.lbs: if wait: - initial_state = self._get_instance_health(lb) + tries = 1 + while True: + initial_state = self._get_instance_health(lb) + if initial_state: + break + time.sleep(1) + tries += 1 + # FIXME: this should be configurable, but since it didn't + # wait at all before this is at least better + if tries > 10: + self.module.fail_json(msg='failed to find the initial state of the load balancer') if enable_availability_zone: self._enable_availailability_zone(lb)