From ac0f6eb063fc5a5c0a9410402ecf57fae1faf594 Mon Sep 17 00:00:00 2001 From: Devananda van der Veen Date: Fri, 1 Mar 2013 14:05:35 -0800 Subject: Compute manager should remove dead resources While most hypervisors return a single - and constant - value from driver.get_available_nodes, baremetal does not. When a node is deleted from the baremetal database, it is no longer returned from driver.get_available_nodes. However, Nova's compute_node record is not directly updated. This patch allows Compute Manager to detect missing nodes within update_available_resources. It then invokes resource_tracker to update the dead node and remove it from compute. This in turn allows the ServiceGroup API to properly update the servicegroup when a baremetal node is no longer in service. Fixes bug 1138184 Change-Id: Icfff3f8e3099668806633a6a58a152b32ec8b49b --- nova/db/api.py | 10 +++++++++- nova/db/sqlalchemy/api.py | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index d14999b45..b921c5a46 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -195,11 +195,19 @@ def compute_node_create(context, values): def compute_node_update(context, compute_id, values, prune_stats=False): """Set the given properties on a computeNode and update it. - Raises NotFound if computeNode does not exist. + Raises ComputeHostNotFound if computeNode does not exist. """ return IMPL.compute_node_update(context, compute_id, values, prune_stats) +def compute_node_delete(context, compute_id): + """Delete a computeNode from the database. + + Raises ComputeHostNotFound if computeNode does not exist. + """ + return IMPL.compute_node_delete(context, compute_id) + + def compute_node_get_by_host(context, host): return IMPL.compute_node_get_by_host(context, host) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index fe3279b2a..d9f9923ed 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -536,6 +536,17 @@ def compute_node_update(context, compute_id, values, prune_stats=False): return compute_ref +@require_admin_context +def compute_node_delete(context, compute_id): + """Delete a ComputeNode record.""" + result = model_query(context, models.ComputeNode).\ + filter_by(id=compute_id).\ + soft_delete() + + if not result: + raise exception.ComputeHostNotFound(host=compute_id) + + def compute_node_get_by_host(context, host): """Get all capacity entries for the given host.""" result = model_query(context, models.ComputeNode, read_deleted="no").\ -- cgit