Merge "Do not update/delete ports upon inspection of active nodes"
This commit is contained in:
commit
6ad813153f
@ -20,7 +20,9 @@ from oslo_utils import netutils
|
||||
from oslo_utils import units
|
||||
import six
|
||||
|
||||
|
||||
from ironic_inspector.common.i18n import _
|
||||
from ironic_inspector.common import ironic as ir_utils
|
||||
from ironic_inspector.plugins import base
|
||||
from ironic_inspector import utils
|
||||
|
||||
@ -274,6 +276,14 @@ class ValidateInterfacesHook(base.ProcessingHook):
|
||||
elif CONF.processing.keep_ports == 'added':
|
||||
expected_macs = set(introspection_data['macs'])
|
||||
|
||||
node_provision_state = node_info.node().provision_state
|
||||
if node_provision_state in ir_utils.VALID_ACTIVE_STATES:
|
||||
LOG.debug('Node %(node)s is %(state)s; '
|
||||
'not modifying / deleting its ports',
|
||||
{'node': node_info.uuid,
|
||||
'state': node_provision_state})
|
||||
return
|
||||
|
||||
if CONF.processing.keep_ports != 'all':
|
||||
# list is required as we modify underlying dict
|
||||
for port in list(node_info.ports().values()):
|
||||
|
@ -322,6 +322,15 @@ class TestValidateInterfacesHookBeforeUpdateDeletion(test_base.NodeTest):
|
||||
mock_delete_port.assert_any_call(self.node_info,
|
||||
self.existing_ports[1])
|
||||
|
||||
def test_active_do_not_delete(self, mock_create_ports, mock_delete_port):
|
||||
CONF.set_override('permit_active_introspection', True, 'processing')
|
||||
CONF.set_override('keep_ports', 'present', 'processing')
|
||||
self.data['all_interfaces'] = self.all_interfaces
|
||||
self.node_info.node().provision_state = 'active'
|
||||
self.hook.before_update(self.data, self.node_info)
|
||||
mock_create_ports.assert_called_once_with(self.node_info, mock.ANY)
|
||||
self.assertFalse(mock_delete_port.called)
|
||||
|
||||
|
||||
@mock.patch.object(node_cache.NodeInfo, 'patch_port', autospec=True)
|
||||
@mock.patch.object(node_cache.NodeInfo, 'create_ports', autospec=True)
|
||||
@ -351,6 +360,12 @@ class TestValidateInterfacesHookBeforeUpdatePXEEnabled(test_base.NodeTest):
|
||||
self.node_info, self.existing_ports[1],
|
||||
[{'op': 'replace', 'path': '/pxe_enabled', 'value': False}])
|
||||
|
||||
def test_active_do_not_modify(self, mock_create_ports, mock_patch_port):
|
||||
CONF.set_override('permit_active_introspection', True, 'processing')
|
||||
self.node_info.node().provision_state = 'active'
|
||||
self.hook.before_update(self.data, self.node_info)
|
||||
self.assertFalse(mock_patch_port.called)
|
||||
|
||||
def test_no_overwrite(self, mock_create_ports, mock_patch_port):
|
||||
CONF.set_override('overwrite_existing', False, 'processing')
|
||||
self.hook.before_update(self.data, self.node_info)
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue happening during manual inspection of
|
||||
active nodes where the code attempts to delete or update
|
||||
ports, while the only modification allowed for active
|
||||
nodes is updating the MAC address if the node is in
|
||||
maintenance.
|
Loading…
Reference in New Issue
Block a user