self.num_instances_by_project is not returned to 0

Bug #1201379 reported by Sergii Kashaba
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Christopher Lefelhocz

Bug Description

I see that for Grizzly update_capabilities method for host manager doesn't reset self.num_instances_by_project if the last VM for some project is deleted on the host.
Is reproduced when working from several tenants simultaneously. For some reason in some cases update messages miss 0 counter for one of tenant;

If it is really the bug, fix can be like
--- a/nova/scheduler/host_manager.py
+++ b/nova/scheduler/host_manager.py
@@ -171,9 +171,12 @@ class HostState(object):
         # Track number of instances by project_id
         project_id_keys = [k for k in statmap.keys() if
             k.startswith("num_proj_")]
- for key in project_id_keys:
- project_id = key[9:]
- self.num_instances_by_project[project_id] = int(statmap[key])
+ project2instance_count = dict([(key[9:], int(statmap[key]))
+ for key in project_id_keys])
+ for key in self.num_instances_by_project:
+ if key not in project2instance_count:
+ self.num_instances_by_project[key] = 0
+ self.num_instances_by_project.update(project2instance_count)

         # Track number of instances in certain vm_states
         vm_state_keys = [k for k in statmap.keys() if k.startswith("num_vm_")]

description: updated
description: updated
description: updated
Changed in nova:
assignee: nobody → Sumanth Nagadavalli (sumanth-nagadavalli)
Revision history for this message
Mathew Odden (locke105) wrote :

Sumanth Nagadavalli are you still working on this?

Changed in nova:
status: New → In Progress
importance: Undecided → Medium
Revision history for this message
Sergii (framin-ksn) wrote :

>>Sumanth Nagadavalli are you still working on this?
We have this fix locally and it works. The deal is that we use custom filtering and our customization rely on this counter.

Changed in nova:
assignee: Sumanth Nagadavalli (sumanth-nagadavalli) → nobody
Tom Fifield (fifieldt)
Changed in nova:
status: In Progress → Confirmed
Revision history for this message
Christopher Lefelhocz (christopher-lefelhoc) wrote :

I will take a crack at this one. Though I may not address the bug quite like the author intends. From what I can tell this is unused code. The calculation num_instances_by_project is never used. As such I'm more inclined to remove the code than add the proposed fix. Strong pushback from core will tell me whether this is appropriate in this case.

Changed in nova:
status: Confirmed → In Progress
assignee: nobody → Christopher Lefelhocz (christopher-lefelhoc)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/105871

Revision history for this message
Andrew Laski (alaski) wrote :

I have a preference for removing code that is not used by any other in-tree code. If you have some filtering that relies on this it would be good to have that, or something closely resembling it, upstream to justify its existence.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/105871
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=d3891b48e75d69a0f618db7c4d0e1b2ce638b980
Submitter: Jenkins
Branch: master

commit d3891b48e75d69a0f618db7c4d0e1b2ce638b980
Author: Christopher Lefelhocz <email address hidden>
Date: Wed Jul 9 15:35:40 2014 -0500

    Remove unused instance variables from HostState

    The request was to fix num_instances_by_project in HostState to
    correctly report state even when last VM was deleted.

    However in investigation I discovered this instance variable isn't
    used in openstack code. Following policy, we should be removing this
    code. Also removed vm_states, task_states and
    num_instances_by_os_type.

    Change-Id: I4ba30a9c0639803d19d5e8355f5bc8dd3f543671
    Closes-Bug: 1201379

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → juno-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-2 → 2014.2
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.