Comment 13 for bug 1423952

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

Reviewed: https://review.openstack.org/163623
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=8c377b2f50345107c96636ce903409b741801c86
Submitter: Jenkins
Branch: stable/juno

commit 8c377b2f50345107c96636ce903409b741801c86
Author: Matt Riedemann <email address hidden>
Date: Wed Mar 11 09:21:29 2015 -0700

    Fix kwargs['instance'] KeyError in @reverts_task_state decorator

    We use @reverts_task_state everywhere in the compute manager and we
    ensure that 'instance' is a parameter to the decorator method via
    @utils.expects_func_args('instance'), however, that only ensures there
    is an instance argument, not that it's in args or kwargs (either is fine
    for what expects_func_args checks).

    The reverts_task_state decorator can get a KeyError when checking
    kwargs['instance'] and fail to revert the task_state on the instance,
    which can leave us in a bad state where non-admins can't delete the
    instance if the task_state is not None (and the reset-state API is
    admin-only).

    This fixes the KeyError in the decorator by normalizing the args/kwargs
    list into a single dict that we can pull the instance from.

    Also adds a warning log if we fail the instance update since it
    shouldn't happen and we want to know if it does because of the
    aforementioned problems with deleting orphaned instances.

    There isn't a specific unit test added for this since moving
    kwargs['instance'] above the try/except in reverts_task_state makes a
    lot of tests fail already if you don't have the normalize code.

    Closes-Bug: #1423952

    Change-Id: I70f464120c798422f9a3d601b7cdf3b0a8320690
    (cherry picked from commit c43f2b0d708f0f4b37850d2917c0abcc13b8789b)