Last active
January 17, 2020 15:12
-
-
Save dosaboy/7dfc8c7ddaea20820a0f175989e20db9 to your computer and use it in GitHub Desktop.
Cleanup compute host resource allocations in placement api left over from Nova bug LP 1756179
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ux | |
# Cleanup compute host resource allocations in placement api left over from Nova bug LP 1756179 | |
# Background: It turns out that when you delete a service the associated resource provider (nova placement api) does not get deleted or updated. | |
mysql -s -N -h$host -u${user} -p$pw nova | |
# Get id of deleted compute host | |
select id from compute_nodes where host="__HOSTNAME_GOES_HERE__" and deleted_at!="NULL"; | |
# First delete any pci_devices records since they have a foreign key constraint on the compute_nodes table | |
delete from pci_devices where compute_node_id="__ID__"; | |
# Check they are gone | |
select * from pci_devices where compute_node_id="__ID__"; | |
# Then delete the old compute node entry | |
delete from compute_nodes where id="__ID__" and deleted_at!="NULL"; | |
# Check it has gone | |
select * from compute_nodes where id="__ID__"; | |
# Get uuid and fqdn of new compute entry | |
select uuid, hypervisor_hostname from compute_nodes where host="__HOSTNAME_GOES_HERE__"; | |
# Then update the resource provider entry for that compute host so that it has the uuid of the new compute host | |
# NOTE: this goes to the nova_api database NOT the nova database | |
mysql -h$host -u${user} -p$pw nova_api | |
update resource_providers set uuid="__UUID__" where name="__FQDN__"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment