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
This commit is contained in:
Ghe Rivero 2014-06-30 23:18:40 +00:00 committed by Ghe Rivero
parent df6176007d
commit e10920e9a7
2 changed files with 7 additions and 3 deletions

View File

@ -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

View File

@ -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')