Exclude deleted service records when calling hypervisor statistics
Hypervisor statistics could be incorrect if not exclude deleted service records from DB. User may stop 'nova-compute' service on some compute nodes and delete the service from nova. When delete 'nova-compute' service, it performs 'soft-delete' to the corresponding db records in both 'service' table and 'compute_nodes' table if the compute_nodes record is old, i.e. it is linked to the service record. For modern compute_nodes records, they aren't linked to the services table so deleting the services record will not delete the compute_nodes record, and the ResourceTracker won't recreate the compute_nodes record if the host and hypervisor_hostname still match the existing record, but restarting the process after deleting the service will create a new services table record with the same host/binary/topic. If the 'nova-compute' service on that server re-starts, it will automatically add a record in 'compute_nodes' table (assuming it was deleted because it was an old-style record) and also a correspoding record in 'service' table, and if the host name of the compute node did not change, the newly created records in 'service' and 'compute_nodes' table will be identical to the priously soft-deleted records except the deleted row. When calling Hypervisor-statistics, the DB layer joined records across the whole deployment by comparing records' host field selected from serivce table and records' host field selected from compute_nodes table, and the calculated results could be multiplied if multiple records from service table have the same host field, and this scenario could happen if user perform the above actions. Co-Authored-By: Matt Riedemann <mriedem.os@gmail.com> Change-Id: I9dfa15f69f8ef9c6cb36b2734a8601bd73e9d6b3 Closes-Bug: #1692397
This commit is contained in:
parent
432cf0eb42
commit
d00b251a33
@ -793,7 +793,8 @@ def compute_node_statistics(context):
|
||||
inner_sel.c.service_id == services_tbl.c.id
|
||||
),
|
||||
services_tbl.c.disabled == false(),
|
||||
services_tbl.c.binary == 'nova-compute'
|
||||
services_tbl.c.binary == 'nova-compute',
|
||||
services_tbl.c.deleted == 0
|
||||
)
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user