Logic in add_host_to_aggregate() is incorrect.

Bug #1208628 reported by Matthew Treinish
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Matthew Treinish

Bug Description

The logic to check if the host being added to an availability zone is already a member of an availability zone in add_host_to_aggregate() added in: I788782a9f21ec2672551f75123753175bb268586 does not work correctly. The db query to get the availability_zone key from the aggregate metadata returns a set of values. However the pop() call only returns the last entry in the set. Additionally, the pop() would not work if db call returned nothing for the az key.

Also there was no protection against the availability zone key not being in the database. So if if an aggregate was created without an availability zone this check would raise a KeyError when you tried to add a host to it.

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/40424

Changed in nova:
status: Triaged → In Progress
Changed in nova:
assignee: Matthew Treinish (treinish) → David Jia (jiataotj)
Changed in nova:
assignee: David Jia (jiataotj) → Matthew Treinish (treinish)
Revision history for this message
Chris Friesen (cbf123) wrote :

I'm not sure the distinction between aggregates and availability zones is totally logical.

It seems to me that the ideal solution would be to throw out the mapping between aggregates and availability zones (or make it a 1:1 mapping), allow a host to be part of mulitple aggregates, and allow an instance to specify multiple aggregates.

Suppose I have aggregates "has_ssd", "has_10g_network", "western_power_grid" and "eastern_power_grid".

Maybe I have a host that matches "has_ssd", "has_10g_network", and "western_power_grid", and another that matches "has_ssd" and "eastern_power_grid".

As an end-user I could spin up an instance (not a flavor) that specifies "has_ssd" and it could go anywhere, while if I specified "has_ssd" and "eastern_power_grid" then it would only go to one specific host.

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

Reviewed: https://review.openstack.org/40424
Committed: http://github.com/openstack/nova/commit/52738c7fa69e960b4cc1562b5933a41ebea0d6cc
Submitter: Jenkins
Branch: master

commit 52738c7fa69e960b4cc1562b5933a41ebea0d6cc
Author: Matthew Treinish <email address hidden>
Date: Mon Aug 5 18:37:47 2013 -0400

    Fix logic in add_host_to_aggregate()

    Commit I788782a9f21ec2672551f75123753175bb268586 introduced some
    changes into the add_host_to_aggregate() method to catch adding an
    host to an availability zone when the host was already a member of
    a different availability zone. However there were a couple of issues
    with this change. There was no check that the availability_zone was
    in the metadata grabbed from the database which would raise a
    KeyError back to the api. Additionally, the check wouldn't always
    work as expected because the database returned a set of availability
    zones (including sometimes an empty set) so the check would fail in
    some conditions when it was expected to pass.

    This commit fixes the logic for checking if the host is already in an
    availability zone. It also replaces the try/except block in the
    aggregates extension to check up front if the action is valid instead
    of waiting for a key error when it goes to use the action.

    Fixes bug 1208627
    Fixes bug 1208628

    Change-Id: I81b79602e23e78c8b077d313e556796de1255bbf

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: havana-3 → 2013.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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