AppScale / appscale-agents

AppScale Cloud Agents
Other
0 stars 7 forks source link

Handle EC2 InvalidInstanceID.NotFound when terminating instances. #4

Closed scragraham closed 5 years ago

scragraham commented 5 years ago

Resolves issue #3

When terminating instances in EC2 it is possible that a subset of instances are already terminated and thus not found by the system. The exception is more likely to originate in the wait_for_status_change() method, but I also handle the possibility of the exception getting thrown when making the call to ec2.terminate_instances.

scragraham commented 5 years ago

Unit test results:

test_ec2_run_instances (test.test_agent_ec2.TestEC2Agent) ... ok
test_ec2_run_instances_agentruntimeexception (test.test_agent_ec2.TestEC2Agent) ... ok
test_ec2_wait_for_status_change_all_not_found_terminated (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_already_terminated (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_invalid_filters (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_keeps_on_running (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_multiple_not_found (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_multiple_not_found_different_order (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_one_not_found_terminated (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_stopped_not_found (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_wait_for_status_change_successfully_terminated (test.test_agent_ec2.TestEC2AgentStatusChange) ... ok
test_ec2_terminate_instances (test.test_agent_ec2.TestEC2AgentTerminateInstances) ... ok
test_ec2_terminate_instances_all_not_found (test.test_agent_ec2.TestEC2AgentTerminateInstances) ... ok
test_ec2_terminate_instances_invalid_id (test.test_agent_ec2.TestEC2AgentTerminateInstances) ... ok
test_ec2_terminate_instances_keeps_running (test.test_agent_ec2.TestEC2AgentTerminateInstances) ... ok
test_ec2_terminate_instances_multiple_invalid_id (test.test_agent_ec2.TestEC2AgentTerminateInstances) ... ok

----------------------------------------------------------------------
Ran 16 tests in 205.215s

OK
scragraham commented 5 years ago

Build: 6389