When shelving a server and saving its new SHELVING task state, we
expect the current task state to be None and do not handle any
UnexpectedTaskStateError exceptions that the database layer may throw
at us. In those cases, we return an error 500 to the user, when in
actuality an error 409 conflict would be more appropriate. This
patch makes the API layer handle UnexpectedTaskStateError exceptions
and return a 409 to the user.
NOTE(artom) Conflicts:
* nova/api/openstack/compute/shelve.py because InstanceUnknownCell stopped being handled as of 95dc5d0ab558604df7d8ef31eba8f9efaee9c474 in train
* nova/tests/unit/api/openstack/compute/test_shelve.py due to the
vm_states import that was present in train as of 27b6c18c666389ee68935f28cf340b7673879d6f but is missing from stein.
Closes-bug: 1850694
Change-Id: Ie0b421cd5d3a5781c1dd09fab4ed013ece0f939d
(cherry picked from commit a423d8b27785623550f401a200b68ca926c0a119)
(cherry picked from commit 32dbd2f585ef1902478170f3a1153b1f71e81db3)
Reviewed: https:/ /review. opendev. org/692630 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=8ee59604dcd 9f770286f54e3a3 9c80f54413c358
Committed: https:/
Submitter: Zuul
Branch: stable/stein
commit 8ee59604dcd9f77 0286f54e3a39c80 f54413c358
Author: Artom Lifshitz <email address hidden>
Date: Wed Oct 30 14:03:49 2019 -0400
Avoid error 500 on shelve task_state race
When shelving a server and saving its new SHELVING task state, we askStateError exceptions that the database layer may throw tateError exceptions
expect the current task state to be None and do not handle any
UnexpectedT
at us. In those cases, we return an error 500 to the user, when in
actuality an error 409 conflict would be more appropriate. This
patch makes the API layer handle UnexpectedTaskS
and return a 409 to the user.
NOTE(artom) Conflicts: openstack/ compute/ shelve. py because
InstanceUnknown Cell stopped being handled as of
95dc5d0ab558604 df7d8ef31eba8f9 efaee9c474 in train unit/api/ openstack/ compute/ test_shelve. py due to the
27b6c18c666389e e68935f28cf340b 7673879d6f but is missing from stein.
* nova/api/
* nova/tests/
vm_states import that was present in train as of
Closes-bug: 1850694 81c1dd09fab4ed0 13ece0f939d 550f401a200b68c a926c0a119) 2478170f3a1153b 1f71e81db3)
Change-Id: Ie0b421cd5d3a57
(cherry picked from commit a423d8b27785623
(cherry picked from commit 32dbd2f585ef190