salt icon indicating copy to clipboard operation
salt copied to clipboard

Temporary failure in name resolution while trying to delete an instance using salt-cloud

Open hernanc opened this issue 12 years ago • 3 comments

Hi there, I'm getting this error when I try to destroy an instance using salt-cloud:

[DEBUG   ] Failed to execute 'ec2.list_nodes()' while querying for running nodes: 'URLError' object has no attribute 'code'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/saltcloud/cloud.py", line 1460, in run_parallel_map_providers_query
    cloud.clouds[data['fun']]()
  File "/usr/local/lib/python2.7/dist-packages/saltcloud/clouds/ec2.py", line 1795, in list_nodes
    nodes = list_nodes_full(get_location())
  File "/usr/local/lib/python2.7/dist-packages/saltcloud/clouds/ec2.py", line 1716, in list_nodes_full
    return _list_nodes_full(location)
  File "/usr/local/lib/python2.7/dist-packages/saltcloud/clouds/ec2.py", line 1749, in _list_nodes_full
    instances = query(params, location=location)
  File "/usr/local/lib/python2.7/dist-packages/saltcloud/clouds/ec2.py", line 274, in query
    exc.code, exc.msg
AttributeError: 'URLError' object has no attribute 'code'

According to this post (http://stackoverflow.com/questions/3465704/python-urllib2-urlerror-http-status-code) "You shouldn't check for a status code after catching URLError, since that exception can be raised in situations where there's no HTTP status code available, for example when you're getting connection refused errors."

And this seems to be the case, as when I've changed my local code to test for the code property like this:

try:
        result = urllib2.urlopen(requesturl)
        log.debug(
            'EC2 Response Status Code: {0}'.format(
                result.getcode()
            )
        )
    except urllib2.URLError as exc:
        if hasattr(exc, 'code'):
                log.error(
                       'EC2 Response Status Code: {0} {1}'.format(
                       exc.code, exc.msg
                       )
                )
        else:
                log.error('EC2 Response Status Code missing {0}'.format(exc.args))
        root = ET.fromstring(exc.read())

I got this error instead:

[ERROR   ] EC2 Response Status Code missing (gaierror(-3, 'Temporary failure in name resolution'),)

Now I'm not sure what's causing that error, I'm running it on an Ubuntu 12.04.5 LTS box

salt --versions-report
           Salt: 2014.1.11
         Python: 2.7.3 (default, Feb 27 2014, 19:58:35)
         Jinja2: 2.6
       M2Crypto: 0.21.1
 msgpack-python: 0.1.10
   msgpack-pure: Not Installed
       pycrypto: 2.4.1
         PyYAML: 3.11
          PyZMQ: 13.0.0
            ZMQ: 3.2.2

#ulimit
unlimited

Any ideas? Thanks.

hernanc avatar Oct 15 '14 18:10 hernanc

Hi @hernanc. We don't use urllib2 in salt-cloud anymore (we switched to requests), and it doesn't look like we're trying to catch that error anymore either. But 2014.1.x is stuck with urllib2, so we'd have to backport a patch to this branch, or just wait for 2014.7.

@basepi can you offer some guidance here?

techhat avatar Oct 15 '14 22:10 techhat

So it turned out I had missconfigured a provider with location: us-east-2. When querying AWS for the box to delete, it was querying ec2.us-east-2.amazonaws.com which apparently doesn't exist -At least I can't ping it. Bottom line: The "Temporary failure in name resolution" was refering to the host being unkown, but I got to that error after touching the code locally to find out what was going on. The error showing up in 2014.1.11 for an unknown host like this one is "'URLError' object has no attribute 'code'" which seems improper.

I consider my issue solved but I'm not sure how you want to deal with the error handling of urllib2 in 2014.1.11. Please let me know if I should close this issue.

Thanks!

hernanc avatar Oct 16 '14 01:10 hernanc

@hernanc Yeah, feel free to close the issue. I'll let @techhat decide if he wants to change the way salt-cloud behaves.

cro avatar Oct 16 '14 12:10 cro