Removing a openstack-hypervisor unit does not clean up the resources correctly.

Bug #2077273 reported by Pedro Castillo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Snap
New
Undecided
Unassigned

Bug Description

When removing an `openstack-hypervisor` unit from a machine, the compute service and hypervisor are not removed from the OpenStack API. Additionally, any VMs running on that node are not removed from the API either.

Given these variables:
```
export JUJU_MODEL=openstack-machines
MACHINE=6
HYPERVISOR_UNIT=$(juju status $MACHINE | awk '/openstack-hypervisor\// {print $1}')
MACHINE_FQDN=$(juju ssh $MACHINE hostname --fqdn | tr -d '\r')
```

Removing the unit will require manual cleanup.
```
juju remove-unit $HYPERVISOR_UNIT
```

This is the manual cleanup required:
```
# Delete VMs from the API.
SERVERS=$(openstack server list --all --host $MACHINE_FQDN -f value -c ID)
for server in $SERVERS; do
    openstack server delete $server
done

# Delete VMs in the machine through Virsh.
juju ssh $MACHINE '
  sudo openstack-hypervisor.virsh list --all --uuid | while read vmid; do
    for cmd in destroy undefine; do
      sudo openstack-hypervisor.virsh $cmd $vmid
    done
  done
'

# Remove the compute service.
COMPUTE_SERVICE=$(openstack compute service list --host $MACHINE_FQDN -f value | awk '$2=="nova-compute" {print $1}')
openstack compute service delete $COMPUTE_SERVICE
```

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.