commit c70e1fbebf5488ca9f6c0ce3658f7583df3bbea5
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)
Reviewed: https:/ /review. openstack. org/163633 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=c70e1fbebf5 488ca9f6c0ce365 8f7583df3bbea5
Committed: https:/
Submitter: Jenkins
Branch: stable/icehouse
commit c70e1fbebf5488c a9f6c0ce3658f75 83df3bbea5
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 expects_ func_args( 'instance' ), however, that only ensures there
ensure that 'instance' is a parameter to the decorator method via
@utils.
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 'instance' ] and fail to revert the task_state on the instance,
kwargs[
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 'instance' ] above the try/except in reverts_task_state makes a
kwargs[
lot of tests fail already if you don't have the normalize code.
Closes-Bug: #1423952
Change-Id: I70f464120c7984 22f9a3d601b7cdf 3b0a8320690 b37850d2917c0ab cc13b8789b)
(cherry picked from commit c43f2b0d708f0f4