Allow deleting nodes with a broken driver
The only reason we need a driver is to stop serial console. Only try to load the driver in this case. Change-Id: I5a4e0a40659042087b7a466baae0a8c3dc136211
This commit is contained in:
parent
3c47122f36
commit
5332588152
@ -1988,6 +1988,7 @@ class ConductorManager(base_manager.BaseConductorManager):
|
||||
# we would disallow it otherwise. That's done for recovering hopelessly
|
||||
# broken nodes (e.g. with broken BMC).
|
||||
with task_manager.acquire(context, node_id,
|
||||
load_driver=False,
|
||||
purpose='node deletion') as task:
|
||||
node = task.node
|
||||
if not node.maintenance and node.instance_uuid is not None:
|
||||
@ -2022,6 +2023,17 @@ class ConductorManager(base_manager.BaseConductorManager):
|
||||
if node.console_enabled:
|
||||
notify_utils.emit_console_notification(
|
||||
task, 'console_set', fields.NotificationStatus.START)
|
||||
|
||||
try:
|
||||
task.load_driver()
|
||||
except Exception:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception('Could not load the driver for node %s '
|
||||
'to shut down its console', node.uuid)
|
||||
notify_utils.emit_console_notification(
|
||||
task, 'console_set',
|
||||
fields.NotificationStatus.ERROR)
|
||||
|
||||
try:
|
||||
task.driver.console.stop_console(task)
|
||||
except Exception as err:
|
||||
|
@ -253,6 +253,10 @@ class TaskManager(object):
|
||||
self.fsm.initialize(start_state=self.node.provision_state,
|
||||
target_state=self.node.target_provision_state)
|
||||
|
||||
def load_driver(self):
|
||||
if self.driver is None:
|
||||
self.driver = driver_factory.build_driver_for_task(self)
|
||||
|
||||
def _lock(self):
|
||||
self._debug_timer.restart()
|
||||
|
||||
|
@ -3609,6 +3609,15 @@ class DestroyNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
||||
self.service.destroy_node(self.context, node.uuid)
|
||||
self.assertFalse(mock_power.called)
|
||||
|
||||
def test_destroy_node_broken_driver(self):
|
||||
node = obj_utils.create_test_node(self.context,
|
||||
power_interface='broken')
|
||||
self._start_service()
|
||||
self.service.destroy_node(self.context, node.uuid)
|
||||
self.assertRaises(exception.NodeNotFound,
|
||||
self.dbapi.get_node_by_uuid,
|
||||
node.uuid)
|
||||
|
||||
|
||||
@mgr_utils.mock_record_keepalive
|
||||
class CreatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
||||
|
5
releasenotes/notes/destroy-broken-8b13de8382199aca.yaml
Normal file
5
releasenotes/notes/destroy-broken-8b13de8382199aca.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Allows deleting nodes with a broken driver unless they require stopping
|
||||
serial console.
|
Loading…
Reference in New Issue
Block a user