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
(cherry picked from commit 5332588152
)
This commit is contained in:
parent
3b1172c7e6
commit
692cf843c6
|
@ -2329,6 +2329,7 @@ class ConductorManager(base_manager.BaseConductorManager):
|
||||||
# we would disallow it otherwise. That's done for recovering hopelessly
|
# we would disallow it otherwise. That's done for recovering hopelessly
|
||||||
# broken nodes (e.g. with broken BMC).
|
# broken nodes (e.g. with broken BMC).
|
||||||
with task_manager.acquire(context, node_id,
|
with task_manager.acquire(context, node_id,
|
||||||
|
load_driver=False,
|
||||||
purpose='node deletion') as task:
|
purpose='node deletion') as task:
|
||||||
node = task.node
|
node = task.node
|
||||||
if not node.maintenance and node.instance_uuid is not None:
|
if not node.maintenance and node.instance_uuid is not None:
|
||||||
|
@ -2363,6 +2364,17 @@ class ConductorManager(base_manager.BaseConductorManager):
|
||||||
if node.console_enabled:
|
if node.console_enabled:
|
||||||
notify_utils.emit_console_notification(
|
notify_utils.emit_console_notification(
|
||||||
task, 'console_set', fields.NotificationStatus.START)
|
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:
|
try:
|
||||||
task.driver.console.stop_console(task)
|
task.driver.console.stop_console(task)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
|
|
@ -253,6 +253,10 @@ class TaskManager(object):
|
||||||
self.fsm.initialize(start_state=self.node.provision_state,
|
self.fsm.initialize(start_state=self.node.provision_state,
|
||||||
target_state=self.node.target_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):
|
def _lock(self):
|
||||||
self._debug_timer.restart()
|
self._debug_timer.restart()
|
||||||
|
|
||||||
|
|
|
@ -5617,6 +5617,15 @@ class DestroyNodeTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
||||||
self.service.destroy_node(self.context, node.uuid)
|
self.service.destroy_node(self.context, node.uuid)
|
||||||
self.assertFalse(mock_power.called)
|
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
|
@mgr_utils.mock_record_keepalive
|
||||||
class CreatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
class CreatePortTestCase(mgr_utils.ServiceSetUpMixin, db_base.DbTestCase):
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Allows deleting nodes with a broken driver unless they require stopping
|
||||||
|
serial console.
|
Loading…
Reference in New Issue