From ffe3093786b137f46646c4cf5fb3ba6b597418a9 Mon Sep 17 00:00:00 2001 From: Jay Faulkner Date: Thu, 26 May 2016 17:31:24 -0700 Subject: [PATCH] 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 --- nova/tests/unit/virt/ironic/test_driver.py | 10 ++++++++-- nova/virt/ironic/driver.py | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/nova/tests/unit/virt/ironic/test_driver.py b/nova/tests/unit/virt/ironic/test_driver.py index b7ea2a822a65..e57264421562 100644 --- a/nova/tests/unit/virt/ironic/test_driver.py +++ b/nova/tests/unit/virt/ironic/test_driver.py @@ -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) diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py index fd2d050317c4..4f6013796931 100644 --- a/nova/virt/ironic/driver.py +++ b/nova/virt/ironic/driver.py @@ -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.