Skip to content

Commit

Permalink
Clean up after the load balancer nodes in case one of them has a prob…
Browse files Browse the repository at this point in the history
…lem while spawning.
  • Loading branch information
tmarballi committed Feb 28, 2018
1 parent 87fbf18 commit 35cb0ae
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions appscale/tools/remote_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,23 @@ def start_all_nodes(cls, options, node_layout):
instance_type_params = params.copy()
instance_type_params['instance_type'] = instance_type

instance_ids, public_ips, private_ips = cls.spawn_nodes_in_cloud(
agent, instance_type_params, count=len(load_balancer_nodes),
load_balancer=True)
try:
instance_ids, public_ips, private_ips = cls.spawn_nodes_in_cloud(
agent, instance_type_params, count=len(load_balancer_nodes),
load_balancer=True)
except (AgentRuntimeException, BotoServerError):
AppScaleLogger.warn("AppScale was unable to start the requested number "
"of instances, attempting to terminate those that "
"were started.")
if len(spawned_instance_ids) > 0:
AppScaleLogger.warn("Attempting to terminate those that were started.")
cls.terminate_spawned_instances(spawned_instance_ids, agent, params)

# Cleanup the keyname since it failed.
LocalState.cleanup_keyname(options.keyname)

# Re-raise the original exception.
raise

# Keep track of instances we have started.
spawned_instance_ids.extend(instance_ids)
Expand Down

0 comments on commit 35cb0ae

Please sign in to comment.