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.09k stars 5.47k forks source link

salt-cloud azurearm Exception raised from VM without a NIC #44320

Closed maxbenson closed 5 years ago

maxbenson commented 6 years ago

Description of Issue/Question

Executing any salt-cloud command with azurearm that calls the list_nodes_full method will throw an exception if there are any nodes in any resource group that do not have a NIC associated with them.

Setup

I'm running on a very recent commit installed with salt-bootstrap: sh bootstrap-salt.sh -M -L -X git e1853e5b5b8109d3b4aebbd22a48b75e92bbb554. I did a quick check of azurearm.py on the 2017.7 branch and it looks like this will encounter the same problem there.

Steps to Reproduce Issue

I originally found this by attempting to destroy a VM with salt-cloud -d <name>; however, it appears to happen with any salt-cloud command that winds up calling the list_nodes_full method. I have a stopped VM in another resource group with no NIC, and this VM isn't related to my salt-cloud command at all. The following stacktrace is the result of running salt-cloud --action show_instance <name> -l debug.

Message: The Resource 'Microsoft.Network/networkInterfaces/<removed vm name>' under resource group '<removed resource group name>' was not found.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 2387, in run_parallel_map_providers_query
    cloud.clouds[data['fun']]()
  File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/azurearm.py", line 401, in list_nodes
    nodes = list_nodes_full(compconn, call)
  File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/azurearm.py", line 437, in list_nodes_full
    private_ips, public_ips = __get_ips_from_node(group, node)
  File "/usr/lib/python2.7/site-packages/salt/cloud/clouds/azurearm.py", line 476, in __get_ips_from_node
    network_interface = netconn.network_interfaces.get(resource_group, node_iface_name)
  File "/usr/lib/python2.7/site-packages/azure/mgmt/network/v2017_09_01/operations/network_interfaces_operations.py", line 177, in get
    raise exp
CloudError: Azure Error: ResourceNotFound

I feel like it should be the responsibility of salt-cloud to sanitize that potential empty result and catch the CloudError raised by network_interfaces_operations.py:177.

Versions Report

Salt Version:
           Salt: 2017.7.0-334-ge1853e5

Dependency Versions:
           cffi: 1.11.2
       cherrypy: Not Installed
       dateutil: 2.6.1
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.18
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.5 (default, Aug  4 2017, 00:39:18)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 15.3.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.1.4

System Versions:
           dist: centos 7.4.1708 Core
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-693.2.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.4.1708 Core

pip freeze:

adal==0.4.7
apache-libcloud==2.0.0rc2
applicationinsights==0.11.1
argcomplete==1.9.2
asn1crypto==0.23.0
azure-batch==4.0.0
azure-batch-extensions==1.0.1
azure-cli==2.0.20
azure-cli-acr==2.0.14
azure-cli-acs==2.0.18
azure-cli-appservice==0.1.19
azure-cli-backup==1.0.2
azure-cli-batch==3.1.6
azure-cli-batchai==0.1.2
azure-cli-billing==0.1.6
azure-cli-cdn==0.0.10
azure-cli-cloud==2.0.9
azure-cli-cognitiveservices==0.1.9
azure-cli-command-modules-nspkg==2.0.1
azure-cli-component==2.0.8
azure-cli-configure==2.0.12
azure-cli-consumption==0.1.6
azure-cli-container==0.1.12
azure-cli-core==2.0.20
azure-cli-cosmosdb==0.1.14
azure-cli-dla==0.0.13
azure-cli-dls==0.0.16
azure-cli-eventgrid==0.1.5
azure-cli-extension==0.0.5
azure-cli-feedback==2.0.6
azure-cli-find==0.2.7
azure-cli-interactive==0.3.11
azure-cli-iot==0.1.13
azure-cli-keyvault==2.0.13
azure-cli-lab==0.0.12
azure-cli-monitor==0.0.11
azure-cli-network==2.0.17
azure-cli-nspkg==3.0.1
azure-cli-profile==2.0.15
azure-cli-rdbms==0.0.8
azure-cli-redis==0.2.10
azure-cli-resource==2.0.17
azure-cli-role==2.0.14
azure-cli-servicefabric==0.0.5
azure-cli-sql==2.0.14
azure-cli-storage==2.0.18
azure-cli-vm==2.0.17
azure-common==1.1.8
azure-datalake-store==0.0.17
azure-graphrbac==0.31.0
azure-keyvault==0.3.7
azure-mgmt-authorization==0.30.0
azure-mgmt-batch==4.1.0
azure-mgmt-batchai==0.2.0
azure-mgmt-billing==0.1.0
azure-mgmt-cdn==0.30.2
azure-mgmt-cognitiveservices==1.0.0
azure-mgmt-compute==3.0.1
azure-mgmt-consumption==0.1.0
azure-mgmt-containerinstance==0.2.0
azure-mgmt-containerregistry==1.0.1
azure-mgmt-containerservice==2.0.0
azure-mgmt-datalake-analytics==0.1.6
azure-mgmt-datalake-nspkg==2.0.0
azure-mgmt-datalake-store==0.1.6
azure-mgmt-devtestlabs==2.0.0
azure-mgmt-dns==1.0.1
azure-mgmt-documentdb==0.1.3
azure-mgmt-eventgrid==0.2.0
azure-mgmt-iothub==0.2.2
azure-mgmt-keyvault==0.40.0
azure-mgmt-monitor==0.3.0
azure-mgmt-network==1.5.0rc3
azure-mgmt-nspkg==2.0.0
azure-mgmt-rdbms==0.1.0
azure-mgmt-recoveryservices==0.1.0
azure-mgmt-recoveryservicesbackup==0.1.1
azure-mgmt-redis==4.1.0
azure-mgmt-resource==1.2.1
azure-mgmt-servicefabric==0.1.0
azure-mgmt-sql==0.8.1
azure-mgmt-storage==1.4.0
azure-mgmt-trafficmanager==0.40.0
azure-mgmt-web==0.33.0
azure-monitor==0.3.0
azure-multiapi-storage==0.1.6
azure-nspkg==2.0.0
azure-storage==0.34.3
Babel==0.9.6
backports.ssl-match-hostname==3.4.0.2
bcrypt==3.1.4
certifi==2017.7.27.1
cffi==1.11.2
chardet==2.2.1
colorama==0.3.9
configobj==4.7.2
cryptography==2.1.2
decorator==3.4.0
enum34==1.1.6
funcsigs==1.0.2
futures==3.0.5
humanfriendly==4.4.1
idna==2.6
iniparse==0.4
ipaddress==1.0.18
isodate==0.6.0
Jinja2==2.7.2
jmespath==0.9.3
keyring==10.4.0
kitchen==1.1.1
langtable==0.0.31
MarkupSafe==0.11
mock==2.0.0
monotonic==1.3
msgpack-python==0.4.8
msrest==0.4.18
msrestazure==0.4.15
oauthlib==2.0.6
paramiko==2.3.1
pathlib==1.0.1
pathlib2==2.3.0
pbr==3.1.1
perf==0.1
prompt-toolkit==1.0.15
psutil==2.2.1
pyasn1==0.3.7
pycparser==2.18
pycrypto==2.6.1
pycurl==7.19.0
pydocumentdb==2.2.1
Pygments==2.2.0
pygobject==3.22.0
pygpgme==0.3
PyJWT==1.5.3
pyliblzma==0.5.3
PyNaCl==1.1.2
pyOpenSSL==17.3.0
python-augeas==0.5.0
python-dateutil==2.6.1
python-dmidecode==3.12.2
python-linux-procfs==0.4.9
pytz==2017.2
pyudev==0.15
pyxattr==0.5.1
PyYAML==3.11
pyzmq==15.3.0
requests==2.6.0
requests-oauthlib==0.8.0
salt==2017.7.0
scandir==1.6
schedutils==0.4
scp==0.10.2
SecretStorage==2.3.1
six==1.9.0
slip==0.4.0
slip.dbus==0.4.0
sshtunnel==0.1.2
tabulate==0.7.7
tornado==4.2.1
urlgrabber==3.10
urllib3==1.22
vsts-cd-manager==1.0.1
wcwidth==0.1.7
Whoosh==2.7.4
xmltodict==0.11.0
yum-langpacks==0.4.2
yum-metadata-parser==1.1.4
stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.