From e10920e9a783cb6aae43bcb2c31b7cfbbfaa9904 Mon Sep 17 00:00:00 2001 From: Ghe Rivero Date: Mon, 30 Jun 2014 23:18:40 +0000 Subject: [PATCH] Fix tear_down a node with missing info When tearing down a node, there could be some situations where the instance info is missing some properties (image source deleted before tearing down the node), so skipping node info validation. Instead, perform a power validation to assure that the node can be power managed. Closes-Bug: #1335909 Closes-Bug: #1345334 Change-Id: Idb1ca720bbd19de1fccfe049e592136dbca2aacf --- ironic/conductor/manager.py | 8 ++++++-- ironic/tests/conductor/test_manager.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ironic/conductor/manager.py b/ironic/conductor/manager.py index 5d8e27e487..209cc343dc 100644 --- a/ironic/conductor/manager.py +++ b/ironic/conductor/manager.py @@ -542,11 +542,15 @@ class ConductorManager(periodic_task.PeriodicTasks): % {'node': node_id, 'state': node.provision_state}) try: - task.driver.deploy.validate(task) + # NOTE(ghe): Valid power driver values are needed to perform + # a tear-down. Deploy info is useful to purge the cache but not + # required for this method. + + task.driver.power.validate(task) except (exception.InvalidParameterValue, exception.MissingParameterValue) as e: raise exception.InstanceDeployFailure(_( - "RPC do_node_tear_down failed to validate deploy info. " + "RPC do_node_tear_down failed to validate power info. " "Error: %(msg)s") % {'msg': e}) # save the previous states so we can rollback the node to a diff --git a/ironic/tests/conductor/test_manager.py b/ironic/tests/conductor/test_manager.py index ecac1bf27d..1a95c85510 100644 --- a/ironic/tests/conductor/test_manager.py +++ b/ironic/tests/conductor/test_manager.py @@ -763,7 +763,7 @@ class DoNodeDeployTearDownTestCase(_ServiceSetUpMixin, # Compare true exception hidden by @messaging.expected_exceptions self.assertEqual(exception.InstanceDeployFailure, exc.exc_info[0]) - @mock.patch('ironic.drivers.modules.fake.FakeDeploy.validate') + @mock.patch('ironic.drivers.modules.fake.FakePower.validate') def test_do_node_tear_down_validate_fail(self, mock_validate): # InvalidParameterValue should be re-raised as InstanceDeployFailure mock_validate.side_effect = exception.InvalidParameterValue('error')