salt-cloud throws an AttributeError when trying to delete nodes via a map file with a non-existant profile

Created on 15 Jun 2016  路  9Comments  路  Source: saltstack/salt

Description of Issue/Question

salt-cloud is throwing an AttributeError when trying to remove nodes defined in a map file when a profile does not exist.

Steps to Reproduce Issue

  1. Create a map file
  2. Create nodes using salt-cloud -m <your_map>
  3. Remove all nodes using salt-cloud -m <your_map> -d

Important: using vultr as a provider but I don't think it really matters.

Trace:

> /usr/lib/python2.7/site-packages/salt/cloud/__init__.py(1713)delete_map()
   1712         for alias, drivers in six.iteritems(query_map.copy()):
-> 1713             for driver, vms in six.iteritems(drivers.copy()):
   1714                 for vm_name, vm_details in six.iteritems(vms.copy()):

ipdb> alias
ipdb> drivers
{'x': "No provider for the mapped 'x' profile was found. Skipped VMS: x"}

While iterating over the next line:

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
AttributeError: 'str' object has no attribute 'copy'
Traceback (most recent call last):
  File "/usr/bin/salt-cloud", line 10, in <module>
    salt_cloud()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 435, in salt_cloud
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cloud/cli.py", line 191, in run
    matching = mapper.delete_map(query='list_nodes')
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1713, in delete_map
    for vm_name, vm_details in six.iteritems(vms.copy()):
AttributeError: 'str' object has no attribute 'copy'
Traceback (most recent call last):
  File "/usr/bin/salt-cloud", line 10, in <module>
    salt_cloud()
  File "/usr/lib/python2.7/site-packages/salt/scripts.py", line 435, in salt_cloud
    client.run()
  File "/usr/lib/python2.7/site-packages/salt/cloud/cli.py", line 191, in run
    matching = mapper.delete_map(query='list_nodes')
  File "/usr/lib/python2.7/site-packages/salt/cloud/__init__.py", line 1713, in delete_map
    for vm_name, vm_details in six.iteritems(vms.copy()):
AttributeError: 'str' object has no attribute 'copy'

Versions Report

Salt Version:
           Salt: 2016.3.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: 0.21.1
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.7
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.5 (default, Nov 20 2015, 02:00:19)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.7.0
           RAET: Not Installed
          smmap: 0.9.0
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: centos 7.2.1511 Core
        machine: x86_64
        release: 3.10.0-327.18.2.el7.x86_64
         system: Linux
        version: CentOS Linux 7.2.1511 Core
Aluminium Bug Community Confirmed RIoT Salt-Cloud phase-plan severity-medium status-in-prog

All 9 comments

@bx2 I am able to replicate this behavior with following test case:

  1. map file:
ec2_centos_6:
  - ch3ll_profile
  1. Create VM: sudo salt-cloud -m /etc/salt/cloud.maps.d/map.map --no-deploy
  2. edit file with bad profile name:
ec2_centos_63j:
  - ch3ll_profile
  1. attempt to delete VM:
sudo salt-cloud -m /etc/salt/cloud.maps.d/map.map -d

AttributeError: 'unicode' object has no attribute 'copy'
Traceback (most recent call last):
  File "/bin/salt-cloud", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/ch3ll/git/salt/scripts/salt-cloud", line 10, in <module>
    salt_cloud()
  File "/home/ch3ll/git/salt/salt/scripts.py", line 428, in salt_cloud
    client.run()
  File "/home/ch3ll/git/salt/salt/cloud/cli.py", line 186, in run
    matching = mapper.delete_map(query='list_nodes')
  File "/home/ch3ll/git/salt/salt/cloud/__init__.py", line 1702, in delete_map
    for vm_name, vm_details in six.iteritems(vms.copy()):
AttributeError: 'unicode' object has no attribute 'copy'

This thing is marked as "High Severity" and open for 18 months. Is this going to be fixed some time soon or could we jump in and try to fix it ourselves?

@scravy this is not currently assigned to our engineers and not scheduled into any of the current sprints. Please feel free to jump in and fix :+1: would greatly appreciate it

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.

@ch3ll sorry, we did not have the capacity to work on this. We found a solution though, we moved to cloudformation.

Thank you for updating this issue. It is no longer marked as stale.

We also encountered this bug:

[ERROR   ] An un-handled exception was caught by salt's global exception handler:
AttributeError: 'str' object has no attribute 'copy'
Traceback (most recent call last):
  File "/root/saltyparrot/venv/bin/salt-cloud", line 10, in <module>
    sys.exit(salt_cloud())
  File "/root/saltyparrot/venv/lib/python3.7/site-packages/salt/scripts.py", line 491, in salt_cloud
    client.run()
  File "/root/saltyparrot/venv/lib/python3.7/site-packages/salt/cloud/cli.py", line 190, in run
    matching = mapper.delete_map(query='list_nodes')
  File "/root/saltyparrot/venv/lib/python3.7/site-packages/salt/cloud/__init__.py", line 1730, in delete_map
    for vm_name, vm_details in six.iteritems(vms.copy()):
AttributeError: 'str' object has no attribute 'copy'
Traceback (most recent call last):
  File "/root/saltyparrot/venv/bin/salt-cloud", line 10, in <module>
    sys.exit(salt_cloud())
  File "/root/saltyparrot/venv/lib/python3.7/site-packages/salt/scripts.py", line 491, in salt_cloud
    client.run()
  File "/root/saltyparrot/venv/lib/python3.7/site-packages/salt/cloud/cli.py", line 190, in run
    matching = mapper.delete_map(query='list_nodes')
  File "/root/saltyparrot/venv/lib/python3.7/site-packages/salt/cloud/__init__.py", line 1730, in delete_map
    for vm_name, vm_details in six.iteritems(vms.copy()):
AttributeError: 'str' object has no attribute 'copy'

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.

Thank you for updating this issue. It is no longer marked as stale.

Was this page helpful?
0 / 5 - 0 ratings