Ironic nodes with instance_uuid are not available

Currently, if a node is in AVAILABLE or NOSTATE (legacy), regardless of
if it has an instance_uuid it is considered able to be scheduled to.
However, it's impossible for a deployment to succeed to an ironic node
with instance_uuid populated. We should not schedule to nodes in this
state.

Change-Id: I41e0c8f1f8a91e11180a6edd72907cf76fe4b235
Closes-bug: 1503453
This commit is contained in:
Jay Faulkner 2016-05-26 17:31:24 -07:00
parent dbf9bf0703
commit ffe3093786
2 changed files with 11 additions and 3 deletions

View File

@ -665,14 +665,20 @@ class IronicDriverTestCase(test.NoDBTestCase):
# a node in deleted
{'uuid': uuidutils.generate_uuid(),
'power_state': ironic_states.POWER_ON,
'provision_state': ironic_states.DELETED}
'provision_state': ironic_states.DELETED},
# a node in AVAILABLE with an instance uuid
{'uuid': uuidutils.generate_uuid(),
'instance_uuid': uuidutils.generate_uuid(),
'power_state': ironic_states.POWER_OFF,
'provision_state': ironic_states.AVAILABLE}
]
for n in node_dicts:
node = ironic_utils.get_test_node(**n)
self.assertTrue(self.driver._node_resources_unavailable(node))
for ok_state in (ironic_states.AVAILABLE, ironic_states.NOSTATE):
# these are both ok and should present as available
# these are both ok and should present as available as they
# have no instance_uuid
avail_node = ironic_utils.get_test_node(
power_state=ironic_states.POWER_OFF,
provision_state=ok_state)

View File

@ -179,7 +179,9 @@ class IronicDriver(virt_driver.ComputeDriver):
ironic_states.AVAILABLE, ironic_states.NOSTATE]
return (node_obj.maintenance or
node_obj.power_state in bad_power_states or
node_obj.provision_state not in good_provision_states)
node_obj.provision_state not in good_provision_states or
(node_obj.provision_state in good_provision_states and
node_obj.instance_uuid is not None))
def _node_resources_used(self, node_obj):
"""Determine whether the node's resources are currently used.