summaryrefslogtreecommitdiff
path: root/ironic/api/controllers
diff options
context:
space:
mode:
authorDmitry Tantsur <dtantsur@redhat.com>2015-07-21 15:16:32 +0200
committerDmitry Tantsur <dtantsur@redhat.com>2015-07-21 15:36:28 +0200
commit685b0d24576a6c8e336d890b220af03ec3c7cc8f (patch)
treee2250ea0c509899b090e185cda879e9fc839a434 /ironic/api/controllers
parent26af388b1bcc0c3e184dbb99e285e522d05b9162 (diff)
downloadironic-685b0d24576a6c8e336d890b220af03ec3c7cc8f.tar.gz
Don't do a premature reservation check in the provision API
This leads to error 409 that have to be retried in client. Instead, only check for reservation if we can't fulfill the request due to invalid state. That will keep backward compatibility while using task_manager retries for node locked case. Change-Id: Iab0a866492dd41d14ed0385c933e8410073694db
Diffstat (limited to 'ironic/api/controllers')
-rw-r--r--ironic/api/controllers/v1/node.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py
index ade977b42..2b095b8fd 100644
--- a/ironic/api/controllers/v1/node.py
+++ b/ironic/api/controllers/v1/node.py
@@ -392,16 +392,6 @@ class NodeStatesController(rest.RestController):
rpc_node = api_utils.get_rpc_node(node_ident)
topic = pecan.request.rpcapi.get_topic_for(rpc_node)
- # Normally, we let the task manager recognize and deal with
- # NodeLocked exceptions. However, that isn't done until the RPC calls
- # below. In order to main backward compatibility with our API HTTP
- # response codes, we have this check here to deal with cases where
- # a node is already being operated on (DEPLOYING or such) and we
- # want to continue returning 409. Without it, we'd return 400.
- if rpc_node.reservation:
- raise exception.NodeLocked(node=rpc_node.uuid,
- host=rpc_node.reservation)
-
if (target in (ir_states.ACTIVE, ir_states.REBUILD)
and rpc_node.maintenance):
raise exception.NodeInMaintenance(op=_('provisioning'),
@@ -410,6 +400,17 @@ class NodeStatesController(rest.RestController):
m = ir_states.machine.copy()
m.initialize(rpc_node.provision_state)
if not m.is_valid_event(ir_states.VERBS.get(target, target)):
+ # Normally, we let the task manager recognize and deal with
+ # NodeLocked exceptions. However, that isn't done until the RPC
+ # calls below.
+ # In order to main backward compatibility with our API HTTP
+ # response codes, we have this check here to deal with cases where
+ # a node is already being operated on (DEPLOYING or such) and we
+ # want to continue returning 409. Without it, we'd return 400.
+ if rpc_node.reservation:
+ raise exception.NodeLocked(node=rpc_node.uuid,
+ host=rpc_node.reservation)
+
raise exception.InvalidStateRequested(
action=target, node=rpc_node.uuid,
state=rpc_node.provision_state)