components/openstack/nova/patches/11-launchpad-1435633.patch
changeset 5450 699a9e31ddae
equal deleted inserted replaced
5449:ba6fc2429fb0 5450:699a9e31ddae
       
     1 This upstream patch has been addressed in Liberty but has not yet been
       
     2 addressed in Kilo.
       
     3 
       
     4 commit c0d0e5ccf62f45498f084ed59e776c3b370e9137
       
     5 Author: jichenjc <[email protected]>
       
     6 Date:   Mon Mar 23 00:36:43 2015 +0800
       
     7 
       
     8     Handle MessageTimeout to MigrationPreCheckError
       
     9     
       
    10     There are a few checks before live-migration, if any of the
       
    11     check failed, the live-migration can't be done. However
       
    12     during _call_livem_checks_on_host check, because it's a
       
    13     RPC call ,so it might result in a MessageTimeout exception.
       
    14     If this occurs, we should safely revert its state,
       
    15     since no real opperation occured.
       
    16     
       
    17     This patch translates the MessageTimeout to
       
    18     MigrationPreCheckError and leverage existing MigrationPreCheckError
       
    19     processing to revert instance to normal state instead of error
       
    20     
       
    21     Closes-Bug: 1435633
       
    22     
       
    23     Change-Id: I8b484abb6650e14e2d225ca5e476d1fa7a6ee990
       
    24 
       
    25 --- nova-2015.1.2/nova/conductor/tasks/live_migrate.py.~1~	2015-10-13 07:52:44.000000000 -0700
       
    26 +++ nova-2015.1.2/nova/conductor/tasks/live_migrate.py	2016-02-10 23:52:06.321170852 -0800
       
    27 @@ -12,6 +12,7 @@
       
    28  
       
    29  from oslo_config import cfg
       
    30  from oslo_log import log as logging
       
    31 +import oslo_messaging as messaging
       
    32  
       
    33  from nova.compute import power_state
       
    34  from nova.compute import rpcapi as compute_rpcapi
       
    35 @@ -140,9 +141,14 @@ class LiveMigrationTask(object):
       
    36              raise exception.DestinationHypervisorTooOld()
       
    37  
       
    38      def _call_livem_checks_on_host(self, destination):
       
    39 -        self.migrate_data = self.compute_rpcapi.\
       
    40 -            check_can_live_migrate_destination(self.context, self.instance,
       
    41 -                destination, self.block_migration, self.disk_over_commit)
       
    42 +        try:
       
    43 +            self.migrate_data = self.compute_rpcapi.\
       
    44 +                check_can_live_migrate_destination(self.context, self.instance,
       
    45 +                    destination, self.block_migration, self.disk_over_commit)
       
    46 +        except messaging.MessagingTimeout:
       
    47 +            msg = _("Timeout while checking if we can live migrate to host: "
       
    48 +                    "%s") % destination
       
    49 +            raise exception.MigrationPreCheckError(msg)
       
    50  
       
    51      def _find_destination(self):
       
    52          # TODO(johngarbutt) this retry loop should be shared
       
    53 --- nova-2015.1.2/nova/tests/unit/conductor/tasks/test_live_migrate.py.~1~	2015-10-13 07:52:44.000000000 -0700
       
    54 +++ nova-2015.1.2/nova/tests/unit/conductor/tasks/test_live_migrate.py	2016-02-10 23:52:46.817923384 -0800
       
    55 @@ -11,6 +11,7 @@
       
    56  #    under the License.
       
    57  
       
    58  from mox3 import mox
       
    59 +import oslo_messaging as messaging
       
    60  
       
    61  from nova.compute import power_state
       
    62  from nova.compute import utils as compute_utils
       
    63 @@ -401,5 +402,12 @@ class LiveMigrationTaskTestCase(test.NoD
       
    64          self.mox.ReplayAll()
       
    65          self.assertRaises(exception.NoValidHost, self.task._find_destination)
       
    66  
       
    67 +    def test_call_livem_checks_on_host(self):
       
    68 +        with mock.patch.object(self.task.compute_rpcapi,
       
    69 +            'check_can_live_migrate_destination',
       
    70 +            side_effect=messaging.MessagingTimeout):
       
    71 +            self.assertRaises(exception.MigrationPreCheckError,
       
    72 +                self.task._call_livem_checks_on_host, {})
       
    73 +
       
    74      def test_not_implemented_rollback(self):
       
    75          self.assertRaises(NotImplementedError, self.task.rollback)