Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

ignore exception if instance doesn't exist in terminate #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amoskong
Copy link
Contributor

Sometimes EC2 failed to create an instance, the instance can't be available.
Problem occurred if our code tries to terminate the instance.

Traceback (most recent call last):
File "/usr/lib64/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.7/site-packages/avocado_ec2/ec2_wrapper.py", line 46, in clean_aws_resources_atexit
instance.terminate()
File "/usr/lib/python2.7/site-packages/boto3/resources/factory.py", line 455, in do_action
response = action(self, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/boto3/resources/action.py", line 79, in call
response = getattr(parent.meta.client, operation_name)(**params)
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 310, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/lib/python2.7/site-packages/botocore/client.py", line 395, in _make_api_call
raise ClientError(parsed_response, operation_name)
ClientError: An error occurred (InvalidInstanceID.NotFound) when calling the TerminateInstances operation: The instance ID 'i-0d0210cadfabc6eba' does not exist

Sometimes EC2 failed to create an instance, the instance can't be available.
Problem occurred if our code tries to terminate the instance.

Traceback (most recent call last):
  File "/usr/lib64/python2.7/atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib/python2.7/site-packages/avocado_ec2/ec2_wrapper.py", line 46, in clean_aws_resources_atexit
    instance.terminate()
  File "/usr/lib/python2.7/site-packages/boto3/resources/factory.py", line 455, in do_action
    response = action(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/boto3/resources/action.py", line 79, in __call__
    response = getattr(parent.meta.client, operation_name)(**params)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 310, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/lib/python2.7/site-packages/botocore/client.py", line 395, in _make_api_call
    raise ClientError(parsed_response, operation_name)
ClientError: An error occurred (InvalidInstanceID.NotFound) when calling the TerminateInstances operation: The instance ID 'i-0d0210cadfabc6eba' does not exist

Signed-off-by: Amos Kong <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant