From 54872f9b6caa1a6ffa06d4cc19d07a04a90b26e1 Mon Sep 17 00:00:00 2001 From: haailani Date: Wed, 17 Aug 2022 06:37:12 +0000 Subject: [PATCH] [SVf]: mkhost failure when volume and node are on different iogrp Attach operation fails when volume and back-end host are on different iogroup. The assignment of the node IP addresses is done outside the try block, and the "for ip_data in lsip_resp" loop. Because of this the loop was not consistent before, so only latest node was detected instead of all nodes. Closes-Bug: #1985065 Change-Id: I72074357140e9817eee704b6e9ebfd7f50343235 --- .../volume/drivers/ibm/test_storwize_svc.py | 60 +++++++++++++++++++ .../ibm/storwize_svc/storwize_svc_common.py | 13 ++-- ...rwize-mkhost-failure-592d8cb76e9feeb2.yaml | 8 +++ 3 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/bug-1985065-storwize-mkhost-failure-592d8cb76e9feeb2.yaml diff --git a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py index 9184b04eaf1..b6b29718563 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_storwize_svc.py @@ -4994,6 +4994,66 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): # Finally, check with good parameters self.driver.do_setup(None) + @mock.patch.object(storwize_svc_common.StorwizeSSH, + 'lsip') + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_node_info') + @mock.patch.object(storwize_svc_common.StorwizeHelpers, + 'get_system_info') + def test_storwize_add_iscsi_ip_address(self, get_system_info, + get_node_info, lsip): + helper = self.driver._master_backend_helpers + helper.state = {'storage_nodes': {}, 'enabled_protocols': set(), + 'compression_enabled': False, 'available_iogrps': [], + 'system_name': None, 'system_id': None, + 'code_level': None} + get_system_info.return_value = {'code_level': (8, 5, 0, 0), + 'topology': 'standard', + 'system_name': 'storwize-svc-sim', + 'system_id': '0123456789ABCDEF'} + + get_node_info.return_value = {'1': {'id': '1', 'name': 'node1', + 'IO_group': 0, + 'iscsi_name': 'test_iscsi1', + 'site_id': '1', + 'site_name': 'site1', + 'ipv4': [], + 'ipv6': [], + 'IP_address': [], + 'WWPN': [], + 'enabled_protocols': [], + 'status': 'online'}, + '2': {'id': '2', 'name': 'node2', + 'IO_group': 1, + 'iscsi_name': 'test_iscsi2', + 'site_id': '1', + 'site_name': 'site1', + 'ipv4': [], + 'ipv6': [], + 'IP_address': [], + 'WWPN': [], + 'enabled_protocols': [], + 'status': 'online'}} + + lsip.return_value = [{'node_id': '1', 'IP_address': '1.1.1.1'}, + {'node_id': '2', 'IP_address': '2.2.2.2'}] + + # Initially the storage_nodes will be empty + self.assertEqual(helper.state["storage_nodes"], {}) + + # _update_storwize_state will update the code_level + # and node info. After that it will call add_iscsi_ip_addrs to + # update the IP_address for the corresponding node_id in storage_nodes + self.driver._update_storwize_state(helper.state, helper) + + # Now, IPs of both the node_id in storage_nodes is updated correctly + # Which means add_iscsi_ip_addrs was successful. + self.assertNotEqual(helper.state["storage_nodes"], {}) + self.assertEqual(helper.state["storage_nodes"]['1']['IP_address'], + ['1.1.1.1']) + self.assertEqual(helper.state["storage_nodes"]['2']['IP_address'], + ['2.2.2.2']) + @mock.patch.object(storwize_svc_common.StorwizeSSH, 'mkhost') def test_storwize_create_host_with_portset(self, mkhost): diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index e4153521308..d43bca35649 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -1105,18 +1105,19 @@ class StorwizeHelpers(object): if code_level >= (8, 4, 2, 0): portset_name = portset if portset else 'portset0' lsip_resp = self.ssh.lsip(portset=portset_name) + # For every node_id there is one IP address in a particular + # portset_name. Hence storing that one IP address of the + # corresponding node_id in storage_node list. for node_data in storage_nodes: - ip_addresses = [] try: for ip_data in lsip_resp: if ip_data['node_id'] in node_data: - if (ip_data['IP_address']): - ip_addresses.append(ip_data['IP_address']) + if ip_data['IP_address']: + (storage_nodes[ip_data['node_id']] + ['IP_address']) = ( + [ip_data['IP_address']]) except KeyError: self.handle_keyerror('lsip', ip_data) - if ip_addresses: - storage_nodes[ip_data['node_id']]['IP_address'] = ( - ip_addresses) else: lsportip_resp = self.ssh.lsportip() for ip_data in lsportip_resp: diff --git a/releasenotes/notes/bug-1985065-storwize-mkhost-failure-592d8cb76e9feeb2.yaml b/releasenotes/notes/bug-1985065-storwize-mkhost-failure-592d8cb76e9feeb2.yaml new file mode 100644 index 00000000000..8a7f28155fc --- /dev/null +++ b/releasenotes/notes/bug-1985065-storwize-mkhost-failure-592d8cb76e9feeb2.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + IBM Spectrum Virtualize Family driver: `Bug #1985065 + `_: + Fixed to collect all the IP addresses for all the storage + nodes given in lsip command response as volume of any iogrp + should be available to the storage nodes in default scenario.