Fix detach_volume calls when rolling back a failed attach
Change I751fcb7532679905c4279744919c6cce84a11eb4 modified
the ComputeDriver.detach_volume method signature to pass
the RequestContext as the first argument. This was missed
in the volume attach rollback code where the driver.detach_volume
method is called. It was missed because that is called
in a try/except block which catches generic Exception, which
also means that the unit test covering that flow, which
raised an Exception, was not failing.
This change fixes the code bug and re-writes the test to
use mock rather than mox and explicitly assert the calls made.
An alternative to this would be changing the generic
Exception handling in the rollback code, however, the
virt drivers raise things other than NovaException, like
os-brick exceptions and libvirtError, so refactoring that
error handling is non-trivial.
Reviewed: https:/ /review. openstack. org/563213 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=717d09149eb ea4d6451efb262f 2b300cdbcf2208
Committed: https:/
Submitter: Zuul
Branch: master
commit 717d09149ebea4d 6451efb262f2b30 0cdbcf2208
Author: Matt Riedemann <email address hidden>
Date: Fri Apr 20 14:18:39 2018 -0400
Fix detach_volume calls when rolling back a failed attach
Change I751fcb75326799 05c4279744919c6 cce84a11eb4 modified detach_ volume method signature to pass detach_ volume
the ComputeDriver.
the RequestContext as the first argument. This was missed
in the volume attach rollback code where the driver.
method is called. It was missed because that is called
in a try/except block which catches generic Exception, which
also means that the unit test covering that flow, which
raised an Exception, was not failing.
This change fixes the code bug and re-writes the test to
use mock rather than mox and explicitly assert the calls made.
An alternative to this would be changing the generic
Exception handling in the rollback code, however, the
virt drivers raise things other than NovaException, like
os-brick exceptions and libvirtError, so refactoring that
error handling is non-trivial.
Change-Id: I9bafd4c47489b6 1973302310720b1 1ec1b5e0374
Closes-Bug: #1765742