From e6fd7e753e3895ba420801099a380717b2100862 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Thu, 4 May 2023 18:01:57 -0700 Subject: [PATCH] Allow md5 to be disabled from the conductor Also fixes my use of set_override, as it is not on the actual config object. You'd think I'd remember that, since I've done that before... Change-Id: I4b578c4319354001cbbd3b3856af96b30fd25555 --- ironic_python_agent/agent.py | 5 +++-- ironic_python_agent/tests/unit/test_agent.py | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ironic_python_agent/agent.py b/ironic_python_agent/agent.py index 3fad86f32..a290c827f 100644 --- a/ironic_python_agent/agent.py +++ b/ironic_python_agent/agent.py @@ -408,8 +408,9 @@ class IronicPythonAgent(base.ExecuteCommandMixin): if config.get('metrics_statsd'): for opt, val in config.items(): setattr(cfg.CONF.metrics_statsd, opt, val) - if config.get('agent_md5_checksum_enable'): - cfg.set_override('md5_enabled', True) + md5_allowed = config.get('agent_md5_checksum_enable') + if md5_allowed is not None: + cfg.CONF.set_override('md5_enabled', md5_allowed) if config.get('agent_token_required'): self.agent_token_required = True token = config.get('agent_token') diff --git a/ironic_python_agent/tests/unit/test_agent.py b/ironic_python_agent/tests/unit/test_agent.py index b5e40bf6c..3f284a896 100644 --- a/ironic_python_agent/tests/unit/test_agent.py +++ b/ironic_python_agent/tests/unit/test_agent.py @@ -230,7 +230,8 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest): 'uuid': 'deadbeef-dabb-ad00-b105-f00d00bab10c' }, 'config': { - 'heartbeat_timeout': 300 + 'heartbeat_timeout': 300, + 'agent_md5_checksum_enable': False } } @@ -246,6 +247,7 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest): mock.call('wait_for_disks')], mock_dispatch.call_args_list) self.agent.heartbeater.start.assert_called_once_with() + self.assertFalse(CONF.md5_enabled) @mock.patch( 'ironic_python_agent.hardware_managers.cna._detect_cna_card', @@ -259,7 +261,7 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest): mock_wait, mock_dispatch): CONF.set_override('inspection_callback_url', '') CONF.set_override('listen_tls', True) - + CONF.set_override('md5_enabled', False) wsgi_server = mock_wsgi.return_value def set_serve_api(): @@ -273,7 +275,8 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest): 'uuid': 'deadbeef-dabb-ad00-b105-f00d00bab10c' }, 'config': { - 'heartbeat_timeout': 300 + 'heartbeat_timeout': 300, + 'agent_md5_checksum_enable': True } } @@ -289,6 +292,7 @@ class TestBaseAgent(ironic_agent_base.IronicAgentTest): mock.call('wait_for_disks')], mock_dispatch.call_args_list) self.agent.heartbeater.start.assert_called_once_with() + self.assertTrue(CONF.md5_enabled) @mock.patch('ironic_lib.mdns.get_endpoint', autospec=True) @mock.patch(