nova compute need update instance to "Error" state.

Bug #1089772 reported by YangLei
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Invalid
Undecided
Unassigned

Bug Description

1. nova compute need update instance to "Error" state.
When the VM is deleted on hypervisor directly, but nova compute just try to update it to "power_state=0, vm_state=stopped and status=SHUTOFF".

2. The steps to recreate the issue.
a. launch instance on openstack
b. delete the VM on hypervisor directly
c. but OpenStack nova compute(the function _sync_power_states(self, context) in nova/compute/manager.py) just try to update instance to power_state=0, vm_state=stopped and status=SHUTOFF

3. The proposal to this issue:
add self._set_instance_error_state() into _sync_power_states(self, context) of nova/compute/manager.py to update instance to Error state.

            elif vm_state == vm_states.ACTIVE:
                # The only rational power state should be RUNNING
                if vm_power_state in (power_state.NOSTATE,
                                       power_state.SHUTDOWN,
                                       power_state.CRASHED):
                    LOG.warn(_("Instance shutdown by itself. Calling "
                               "the stop API."), instance=db_instance)
                    try:
                        # Note(maoy): here we call the API instead of
                        # brutally updating the vm_state in the database
                        # to allow all the hooks and checks to be performed.
                        self.compute_api.stop(context, db_instance)
                    except Exception:
                        # Note(maoy): there is no need to propagate the error
                        # because the same power_state will be retrieved next
                        # time and retried.
                        # For example, there might be another task scheduled.
                        LOG.exception(_("error during stop() in "
                                        "sync_power_state."),
                                      instance=db_instance)
                        self._set_instance_error_state(context, db_instance['uuid'])
                elif vm_power_state in (power_state.PAUSED,
                                        power_state.SUSPENDED):
                    LOG.warn(_("Instance is paused or suspended "
                               "unexpectedly. Calling "
                               "the stop API."), instance=db_instance)
                    try:
                        self.compute_api.stop(context, db_instance)
                    except Exception:
                        LOG.exception(_("error during stop() in "
                                        "sync_power_state."),
                                      instance=db_instance)
                        self._set_instance_error_state(context, db_instance['uuid'])
            elif vm_state == vm_states.STOPPED:
                if vm_power_state not in (power_state.NOSTATE,
                                          power_state.SHUTDOWN,
                                          power_state.CRASHED):
                    LOG.warn(_("Instance is not stopped. Calling "
                               "the stop API."), instance=db_instance)
                    try:
                        # Note(maoy): this assumes that the stop API is
                        # idempotent.
                        self.compute_api.stop(context, db_instance)
                    except Exception:
                        LOG.exception(_("error during stop() in "
                                        "sync_power_state."),
                                      instance=db_instance)
                elif vm_power_state == power_state.NOSTATE:
                    LOG.warn(_("Instance is NOSTATE"), instance=db_instance)
                    self._set_instance_error_state(context, db_instance['uuid'])

Revision history for this message
Russell Bryant (russellb) wrote :

It's obviously not normal operation to delete a VM from outside of nova.

Aside from that, nova's behavior seems reasonable anyway. Once you try to go turn it on, I assume it goes into an Error state?

Changed in nova:
status: New → Invalid
status: Invalid → Incomplete
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

We cannot solve the issue you reported without more information. Could you please provide the requested information ?

Michael Still (mikal)
Changed in nova:
status: Incomplete → Invalid
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.