saltstack / saltstack/salt

ssh key deletion in instance deletion fails with openstack driver in salt-cloud

Open
#52,991 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Confirmed openstack severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue/Question

When deleting an instance with salt-cloud -d with openstack driver, ssh key removal fail and I get an error message sayng [ERROR ] There was an error destroying machines: 'dict' object has no attribute 'public_ips'

There are two problems in this line

https://github.com/saltstack/salt/blob/b2258397cb9018530cf2acba28447a047151fbc5/salt/cloud/clouds/openstack.py#L809

First, node is a dict, not an object, so getattr(node, ...) should be replaced by node.get(...). We are looking for a key, not an attribute.

Secondly, ssh_interface is not a first level member of __opts__ but appears deeper in the structure, either in provider, profile or instance level, so __opts__.get('ssh_interface', 'public_ips') always returns public_ips regardless of what you have configured as ssh_interface.

Setup

salt-cloud 2019.2 from official repo on Debian 9 stretch

Steps to Reproduce Issue
  • Configure salt-cloud with openstack driver and ssh_interface: private_ips
  • Destroy an instance
  • Look at the error message (first problem) and see it still look for public_ips (second problem)
Versions Report
# salt -V
Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: 1.12.3
       cherrypy: Not Installed
       dateutil: 2.5.3
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.9.4
        libgit2: 0.24.5
        libnacl: Not Installed
       M2Crypto: 0.24.0
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.8
   mysql-python: Not Installed
      pycparser: 2.19
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: 0.24.2
         Python: 2.7.13 (default, Sep 26 2018, 18:42:22)
   python-gnupg: Not Installed
         PyYAML: 3.12
          PyZMQ: 16.0.2
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.4.3
            ZMQ: 4.2.1
 
System Versions:
           dist: debian 9.9 
         locale: UTF-8
        machine: x86_64
        release: 4.9.0-8-amd64
         system: Linux
        version: debian 9.9 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at salt/cloud/clouds/openstack.py line 809 and inspect how the node data and ssh_interface configuration are read during salt-cloud -d. Reproduce with an OpenStack profile using ssh_interface: private_ips, then verify instance deletion removes the SSH key without the public_ips error and respects the configured interface.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.