From b7a3772d9053e797235c9ba26965c91e45b823f7 Mon Sep 17 00:00:00 2001 From: Tzu-Mainn Chen Date: Thu, 13 Jul 2023 17:33:43 +0000 Subject: [PATCH] Fix bug that causes expired leases to not be reflected on ironic nodes The ironic_node resource_object automatically popped the lease_uuid from its properties dict when calling get_config. However, this is permanently reflected on the resource object, and results in future queries of the resource object's lease_uuid returning None. --- esi_leap/objects/lease.py | 4 +++- esi_leap/resource_objects/ironic_node.py | 1 - esi_leap/tests/resource_objects/test_ironic_node.py | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/esi_leap/objects/lease.py b/esi_leap/objects/lease.py index f520e29d..e62176cd 100644 --- a/esi_leap/objects/lease.py +++ b/esi_leap/objects/lease.py @@ -100,7 +100,9 @@ def __init__(self, lease, node): setattr(node, 'node_name', node.get_name()) setattr(node, 'node_provision_state', node.get_node_provision_state()) setattr(node, 'node_power_state', node.get_node_power_state()) - setattr(node, 'node_properties', node.get_config()) + node_config = node.get_config().copy() + node_config.pop('lease_uuid', None) + setattr(node, 'node_properties', node_config) self.populate_schema(lease=lease, node=node) diff --git a/esi_leap/resource_objects/ironic_node.py b/esi_leap/resource_objects/ironic_node.py index 9f575d3e..b7a35ebf 100644 --- a/esi_leap/resource_objects/ironic_node.py +++ b/esi_leap/resource_objects/ironic_node.py @@ -65,7 +65,6 @@ def get_config(self): config = self._get_node_attr('properties', {}, err_msg='Error getting resource config', err_val=error.UNKNOWN['config']) - config.pop('lease_uuid', None) return config def get_owner_project_id(self): diff --git a/esi_leap/tests/resource_objects/test_ironic_node.py b/esi_leap/tests/resource_objects/test_ironic_node.py index a70752cd..6d8e2054 100644 --- a/esi_leap/tests/resource_objects/test_ironic_node.py +++ b/esi_leap/tests/resource_objects/test_ironic_node.py @@ -94,7 +94,6 @@ def test_get_config(self, mock_gn): config = test_ironic_node.get_config() expected_config = fake_get_node.properties - expected_config.pop('lease_uuid', None) self.assertEqual(config, expected_config) mock_gn.assert_called_once()