os-migrateLive fault but rest api raise a incorrect conflict message

Bug #1437111 reported by Eli Qiao
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Eli Qiao

Bug Description

when do a live migration which the instance is in a state like this
taget@liyong:~/devstack$ nova list
+--------------------------------------+-------+--------+------------+-------------+----------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+----------------------+
| 1d114104-9a62-49ba-b209-6a42beff4133 | test1 | ACTIVE | - | NOSTATE | private_net=10.0.0.9 |
+--------------------------------------+-------+--------+------------+-------------+----------------------+

rest api raise conflictRequest, this is correct, but the message is not correct.

(0, '{"conflictingRequest": {"message": "Instance 1d114104-9a62-49ba-b209-6a42beff4133 is in an invalid state for \'os-migrateLive\'", "code": 409}}', ' % Total % Received % Xferd Average Speed Time Time Time Current\n Dload Upload Total Spent Left Speed\n\r 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0\r100 92 0 0 100 92 0 76 0:00:01 0:00:01 --:--:-- 76\r100 233 100 141 100 92 78 51 0:00:01 0:00:01 --:--:-- 78\r100 233 100 141 100 92 78 51 0:00:01 0:00:01 --:--:-- 78\n')

in live_migrate.py, we check if instance in active state, it do the right thing.

    def _check_instance_is_active(self):
        if self.instance.power_state not in (power_state.RUNNING,
                                             power_state.PAUSED):
            raise exception.InstanceInvalidState(
                    instance_uuid = self.instance.uuid,
                    attr = 'power_state',
                    state = self.instance.power_state,
                    method = 'live migrate')

but in this case, power_state is an Integer zero,
the logic in raise_http_conflict_for_instance_invalid_state

by checking code of raise_http_conflict_for_instance_invalid_state

def raise_http_conflict_for_instance_invalid_state(exc, action, server_id):
    """Raises a webob.exc.HTTPConflict instance containing a message
    appropriate to return via the API based on the original
    InstanceInvalidState exception.
    """
    attr = exc.kwargs.get('attr')
    state = exc.kwargs.get('state')
    not_launched = exc.kwargs.get('not_launched')
    if attr and state: <<<<<<<<<<<<<------------ should go this condition but state is zero.
        msg = _("Cannot '%(action)s' instance %(server_id)s while it is in "
                "%(attr)s %(state)s") % {'action': action, 'attr': attr,
                                         'state': state,
                                         'server_id': server_id}

Tags: api
Eli Qiao (taget-9)
Changed in nova:
assignee: nobody → Eli Qiao (taget-9)
status: New → Confirmed
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/168211

Changed in nova:
status: Confirmed → In Progress
Changed in nova:
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/168211
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=70f3c8d3d33a12ee002753f7867c6c12d2b0fc84
Submitter: Jenkins
Branch: master

commit 70f3c8d3d33a12ee002753f7867c6c12d2b0fc84
Author: Eli Qiao <email address hidden>
Date: Fri Mar 27 10:15:38 2015 +0800

    Fix incorrect http_conflict error message

    instance power state may be integer zero, in that case the error message would
    be no correct.

    BTW, this patch remove 'not_launched' from kwargs since no other code set this
    parameter into kwargs.

    Closes-bug: 1437111
    Change-Id: Id2fb561a79d627eb8c6b41e4fe3549dc69dc7d99

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

Other bug subscribers

Remote bug watches

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