saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.16k stars 5.48k forks source link

2015.8 - Azure add endpoint not working anymore: TypeError: 'NoneType' object is not iterable #25463

Closed h0jeZvgoxFepBQ2C closed 9 years ago

h0jeZvgoxFepBQ2C commented 9 years ago

Tried to add an endpoint, worked before (but also doesnt work anymore in 2015.5? did azure api change maybe?):

# salt-cloud -f add_input_endpoint az-mysetup name=http    port=80    protocol=tcp deployment=myproject service=myproject role=myproject

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/cli.py", line 245, in run
    self.function_provider, self.function_name, kwargs
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1525, in do_function
    call='function', kwargs=kwargs
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/clouds/msazure.py", line 2190, in add_input_endpoint
    activity='add',
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/clouds/msazure.py", line 2109, in update_input_endpoint
    old_endpoints = list_input_endpoints(kwargs, call='function')
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/clouds/msazure.py", line 2013, in list_input_endpoints
    for item in data:
TypeError: 'NoneType' object is not iterable
salt-ssh --versions-report
Salt Version:
           Salt: 2015.5.0-1767-gba4877d

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: 0.22
           Mako: 1.0.1
         PyYAML: 3.11
          PyZMQ: 14.6.0
         Python: 2.7.9 (default, Jan  7 2015, 11:50:42)
           RAET: Not Installed
        Tornado: 4.1
            ZMQ: 4.0.5
          ioflo: 1.2.1
        libnacl: Not Installed
   msgpack-pure: 0.1.3
 msgpack-python: 0.4.6
       pycrypto: 2.6.1

System Versions:
           dist:
        machine: x86_64
        release: 13.4.0
         system: 10.9.5 -- x86_64
jfindlay commented 9 years ago

@lichtamberg, based on the salt version reported it seems that you are running an old version of develop. Is it possible for you to try again with 2015.5.3, 2015.8.0rc1 or the heads of those branches or even develop? Thanks.

h0jeZvgoxFepBQ2C commented 9 years ago

@jfindlay I tried it with the last 2015.8.rc1 branch, still not working..

Salt Version:
           Salt: 2015.8.0rc1-44-gcef7461

Dependency Versions:
         Jinja2: 2.7.3
       M2Crypto: 0.22
           Mako: 1.0.1
         PyYAML: 3.11
          PyZMQ: 14.6.0
         Python: 2.7.9 (default, Jan  7 2015, 11:50:42)
           RAET: Not Installed
        Tornado: 4.1
            ZMQ: 4.0.5
          ioflo: 1.2.1
        libnacl: Not Installed
   msgpack-pure: 0.1.3
 msgpack-python: 0.4.6
       pycrypto: 2.6.1

System Versions:
           dist:
        machine: x86_64
        release: 13.4.0
         system: 10.9.5 -- x86_64

Different line numbers, but same error:

[ERROR   ] There was an error running the function: 'NoneType' object is not iterable
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/cli.py", line 245, in run
    self.function_provider, self.function_name, kwargs
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1525, in do_function
    call='function', kwargs=kwargs
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/clouds/msazure.py", line 2193, in add_input_endpoint
    activity='add',
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/clouds/msazure.py", line 2112, in update_input_endpoint
    old_endpoints = list_input_endpoints(kwargs, call='function')
  File "/usr/local/lib/python2.7/site-packages/salt/cloud/clouds/msazure.py", line 2016, in list_input_endpoints
    for item in data:
TypeError: 'NoneType' object is not iterable
jfindlay commented 9 years ago

Thanks, @lichtamberg.

h0jeZvgoxFepBQ2C commented 9 years ago

Found the issue...

Was a mistake of mine, I sent the endpoint call to the wrong account on azure (which didnt has this service/server running)... Maybe there should be a better error message and a validation, if the mentioned service really exists...

rallytime commented 9 years ago

@lichtamberg Another thing I just noticed when looking into this bug is that the add_input_endpoint function was added in 2015.8.0, so it is not available in the 2015.5.x releases. Just a note in case other people come across this in the future.

rallytime commented 9 years ago

@lichtamberg Also, I've fixed the stacktrace above by providing a more helpful error:

There was an error connecting to the Azure API. Please check your credentials.

Sound good?

h0jeZvgoxFepBQ2C commented 9 years ago

Hey @rallytime ,

thanks for your response.. This error message seems much better, but: it would have been missleading for me... My problem was not that my credentials were wrong... They were correct, but I just mixed up that under this credentials there was no server running with the name "xyz" (was running under another subscription)...

So the error message should be something like: "No server xyz found with this credentials" (if the credentials are correct)..

Thanks!

rallytime commented 9 years ago

@lichtamberg Ok, I'll see if I can be a little more specific. The problem is that the stacktrace occurs because the query to the Azure API is returning None, so I was purposefully trying to not be too specific since you could potentially hit that error many different ways, not just the way you're hitting it. I'll see if I can narrow it down tomorrow.

rallytime commented 9 years ago

@lichtamberg You're right - this error could be much more friendly. I've changed it to:

There was an error listing endpoints with the <abc-service> service on the <xyz-deployment> deployment.

Which will be both broad and more helpful/accurate than my first message.

h0jeZvgoxFepBQ2C commented 9 years ago

@rallytime thank you very much! :)

rallytime commented 9 years ago

No problem! Thanks for the feedback! :)