get-vnc-console returns 500 if instance in invalid task_state

Bug #1968618 reported by Ksenia Kargina
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
李学海

Bug Description

Description
===========
Nova returns 500 when you create console for instance which is in transition state like deleting or migrating.

Steps to reproduce
==================
1. Instance in task_state deleting or migrating

mysql> select task_state from instances where uuid='35a5c36e-5464-4747-97a8-c160da093101';
+------------+
| task_state |
+------------+
| migrating |
+------------+

2. Try to get console

# openstack console url show --novnc 35a5c36e-5464-4747-97a8-c160da093101
Unexpected API Error. Please report this at http://bugs.launchpad.net/nova/ and attach the Nova API log if possible.
<class 'nova.exception.InstanceInvalidState'> (HTTP 500) (Request-ID: req-8dd68e78-1956-4e0c-90ee-d2a5e1be54bf)

Same error with "nova get-vnc-console"

Expected result
===============
Nova usually returns HTTP 409 when catches InstanceInvalidState.

Environment
===========
Currently seeing in Stein. But it seems nova doesn't catch this exception in other versions.

Logs & Configs
==============
2022-04-11 18:59:24,404.404 11 ERROR nova.api.openstack.wsgi [req-f057dae1-9a9a-4db5-8faf-db655b904a0e b6ba9c75146a49829a7427a3e8cc3c10 192796e61c174f718d6147b129f3f2ff] Unexpected exception in API method: nova.exception.InstanceInvalidState: Instance 35a5c36e-5464-4747-97a8-c160da093101 in task_state migrating. Cannot get_vnc_console while the instance is in this state.
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi Traceback (most recent call last):
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi File "/var/lib/openstack/lib/python3.6/site-packages/nova/api/openstack/wsgi.py", line 671, in wrapped
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi return f(*args, **kwargs)
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi File "/var/lib/openstack/lib/python3.6/site-packages/nova/api/validation/__init__.py", line 110, in wrapper
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi return func(*args, **kwargs)
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi File "/var/lib/openstack/lib/python3.6/site-packages/nova/api/validation/__init__.py", line 110, in wrapper
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi return func(*args, **kwargs)
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi File "/var/lib/openstack/lib/python3.6/site-packages/nova/api/openstack/compute/remote_consoles.py", line 168, in create
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi output = handler(context, instance, console_type)
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi File "/var/lib/openstack/lib/python3.6/site-packages/nova/compute/api.py", line 199, in wrapped
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi return function(self, context, instance, *args, **kwargs)
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi File "/var/lib/openstack/lib/python3.6/site-packages/nova/compute/api.py", line 187, in inner
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi attr='task_state', state=instance.task_state)
2022-04-11 18:59:24,404.404 11 TRACE nova.api.openstack.wsgi nova.exception.InstanceInvalidState: Instance 35a5c36e-5464-4747-97a8-c160da093101 in task_state migrating. Cannot get_vnc_console while the instance is in this state.

Revision history for this message
Sylvain Bauza (sylvain-bauza) wrote :

Looks we miss an exception handling here.

Changed in nova:
status: New → Confirmed
importance: Undecided → Low
tags: added: low-hanging-fruit
tags: added: console
李学海 (lixuehai)
Changed in nova:
assignee: nobody → 李学海 (lixuehai)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/nova/+/861738

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

Reviewed: https://review.opendev.org/c/openstack/nova/+/861738
Committed: https://opendev.org/openstack/nova/commit/ec40d5aee34e9428e2a19231fc3df4d23d75b779
Submitter: "Zuul (22348)"
Branch: master

commit ec40d5aee34e9428e2a19231fc3df4d23d75b779
Author: Rajesh Tailor <email address hidden>
Date: Tue Oct 11 18:01:17 2022 +0530

    Handle InstanceInvalidState exception

    When instance task state is 'deleting' or 'migrating', then
    get_vnc_console throws 500 error, as InstanceInvalidState
    exception is not handled there.

    This change handles InstanceInvalidState in api layer in
    get_vnc_console call.

    Closes-Bug: #1968618
    Change-Id: Ia738a0972b050f549f446c85171d3f33e60ada4f

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/zed)

Fix proposed to branch: stable/zed
Review: https://review.opendev.org/c/openstack/nova/+/872115

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/yoga)

Fix proposed to branch: stable/yoga
Review: https://review.opendev.org/c/openstack/nova/+/872117

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/xena)

Fix proposed to branch: stable/xena
Review: https://review.opendev.org/c/openstack/nova/+/875345

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/wallaby)

Fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/nova/+/875346

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (stable/victoria)

Fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/openstack/nova/+/875348

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 27.0.0.0rc1

This issue was fixed in the openstack/nova 27.0.0.0rc1 release candidate.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/zed)

Reviewed: https://review.opendev.org/c/openstack/nova/+/872115
Committed: https://opendev.org/openstack/nova/commit/71855163a944e437f9c48a5765f683b55a28c720
Submitter: "Zuul (22348)"
Branch: stable/zed

commit 71855163a944e437f9c48a5765f683b55a28c720
Author: Rajesh Tailor <email address hidden>
Date: Tue Oct 11 18:01:17 2022 +0530

    Handle InstanceInvalidState exception

    When instance task state is 'deleting' or 'migrating', then
    get_vnc_console throws 500 error, as InstanceInvalidState
    exception is not handled there.

    This change handles InstanceInvalidState in api layer in
    get_vnc_console call.

    Closes-Bug: #1968618
    Change-Id: Ia738a0972b050f549f446c85171d3f33e60ada4f
    (cherry picked from commit ec40d5aee34e9428e2a19231fc3df4d23d75b779)

tags: added: in-stable-zed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (stable/yoga)

Reviewed: https://review.opendev.org/c/openstack/nova/+/872117
Committed: https://opendev.org/openstack/nova/commit/286aadf289ef1b001ba7816e20b8cd53ba7a8618
Submitter: "Zuul (22348)"
Branch: stable/yoga

commit 286aadf289ef1b001ba7816e20b8cd53ba7a8618
Author: Rajesh Tailor <email address hidden>
Date: Tue Oct 11 18:01:17 2022 +0530

    Handle InstanceInvalidState exception

    When instance task state is 'deleting' or 'migrating', then
    get_vnc_console throws 500 error, as InstanceInvalidState
    exception is not handled there.

    This change handles InstanceInvalidState in api layer in
    get_vnc_console call.

    Closes-Bug: #1968618
    Change-Id: Ia738a0972b050f549f446c85171d3f33e60ada4f
    (cherry picked from commit ec40d5aee34e9428e2a19231fc3df4d23d75b779)
    (cherry picked from commit 71855163a944e437f9c48a5765f683b55a28c720)

tags: added: in-stable-yoga
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 26.1.1

This issue was fixed in the openstack/nova 26.1.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 25.2.0

This issue was fixed in the openstack/nova 25.2.0 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (stable/victoria)

Change abandoned by "Elod Illes <email address hidden>" on branch: stable/victoria
Review: https://review.opendev.org/c/openstack/nova/+/875348
Reason: stable/victoria branch of openstack/nova is about to be deleted. To be able to do that, all open patches need to be abandoned. Please cherry pick the patch to unmaintained/victoria if you want to further work on this patch.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (stable/wallaby)

Change abandoned by "Elod Illes <email address hidden>" on branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/nova/+/875346
Reason: stable/wallaby branch of openstack/nova is about to be deleted. To be able to do that, all open patches need to be abandoned. Please cherry pick the patch to unmaintained/wallaby if you want to further work on this patch.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (stable/xena)

Change abandoned by "Elod Illes <email address hidden>" on branch: stable/xena
Review: https://review.opendev.org/c/openstack/nova/+/875345
Reason: stable/xena branch of openstack/nova is about to be deleted. To be able to do that, all open patches need to be abandoned. Please cherry pick the patch to unmaintained/xena if you want to further work on this patch.

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.