Hitachi: Fix to set correct object ID for LDEV nickname

The patch fixes to set correct object ID for LDEV nickname.

Closes-Bug: #2071697
Change-Id: I2a2cfb44207b03fbb006d29ae958896f3f3231ed
This commit is contained in:
Atsushi Kawai 2024-07-03 15:12:11 +09:00
parent 0f649dcedd
commit 1895845dcf
13 changed files with 92 additions and 16 deletions

View File

@ -1286,7 +1286,9 @@ class HBSDMIRRORFCDriverTest(test.TestCase):
@mock.patch.object(requests.Session, "request")
def test_update_migrated_volume(self, request):
request.side_effect = [FakeResponse(200, GET_LDEV_RESULT),
FakeResponse(200, COMPLETED_SUCCEEDED_RESULT)]
FakeResponse(202, COMPLETED_SUCCEEDED_RESULT),
FakeResponse(200, GET_LDEV_RESULT),
FakeResponse(202, COMPLETED_SUCCEEDED_RESULT)]
self.assertRaises(
NotImplementedError,
self.driver.update_migrated_volume,
@ -1294,7 +1296,31 @@ class HBSDMIRRORFCDriverTest(test.TestCase):
TEST_VOLUME[0],
TEST_VOLUME[1],
"available")
self.assertEqual(2, request.call_count)
self.assertEqual(4, request.call_count)
args, kwargs = request.call_args_list[3]
self.assertEqual(kwargs['json']['label'],
TEST_VOLUME[0]['id'].replace("-", ""))
@mock.patch.object(requests.Session, "request")
def test_update_migrated_volume_replication(self, request):
request.side_effect = [FakeResponse(200, GET_LDEV_RESULT_REP),
FakeResponse(202, COMPLETED_SUCCEEDED_RESULT),
FakeResponse(202, COMPLETED_SUCCEEDED_RESULT),
FakeResponse(200, GET_LDEV_RESULT_REP),
FakeResponse(202, COMPLETED_SUCCEEDED_RESULT),
FakeResponse(202, COMPLETED_SUCCEEDED_RESULT)]
self.assertRaises(
NotImplementedError,
self.driver.update_migrated_volume,
self.ctxt,
TEST_VOLUME[0],
TEST_VOLUME[4],
"available")
self.assertEqual(6, request.call_count)
original_volume_nickname = TEST_VOLUME[0]['id'].replace("-", "")
for i in (4, 5):
args, kwargs = request.call_args_list[i]
self.assertEqual(kwargs['json']['label'], original_volume_nickname)
def test_unmanage_snapshot(self):
"""The driver don't support unmange_snapshot."""

View File

@ -1305,7 +1305,10 @@ class HBSDRESTFCDriverTest(test.TestCase):
TEST_VOLUME[0],
TEST_VOLUME[1],
"available")
self.assertEqual(1, request.call_count)
self.assertEqual(2, request.call_count)
args, kwargs = request.call_args_list[1]
self.assertEqual(kwargs['json']['label'],
TEST_VOLUME[0]['id'].replace("-", ""))
def test_unmanage_snapshot(self):
"""The driver don't support unmange_snapshot."""

View File

@ -867,7 +867,10 @@ class HBSDRESTISCSIDriverTest(test.TestCase):
TEST_VOLUME[0],
TEST_VOLUME[1],
"available")
self.assertEqual(1, request.call_count)
self.assertEqual(2, request.call_count)
args, kwargs = request.call_args_list[1]
self.assertEqual(kwargs['json']['label'],
TEST_VOLUME[0]['id'].replace("-", ""))
def test_unmanage_snapshot(self):
"""The driver don't support unmange_snapshot."""

View File

@ -1,4 +1,4 @@
# Copyright (C) 2022, 2023, Hewlett Packard Enterprise, Ltd.
# Copyright (C) 2022, 2024, Hewlett Packard Enterprise, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -955,7 +955,10 @@ class HPEXPRESTFCDriverTest(test.TestCase):
TEST_VOLUME[0],
TEST_VOLUME[1],
"available")
self.assertEqual(1, request.call_count)
self.assertEqual(2, request.call_count)
args, kwargs = request.call_args_list[1]
self.assertEqual(kwargs['json']['label'],
TEST_VOLUME[0]['id'].replace("-", ""))
def test_unmanage_snapshot(self):
"""The driver don't support unmange_snapshot."""

View File

@ -1,4 +1,4 @@
# Copyright (C) 2022, 2023. Hewlett Packard Enterprise, Ltd.
# Copyright (C) 2022, 2024, Hewlett Packard Enterprise, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -768,7 +768,10 @@ class HPEXPRESTISCSIDriverTest(test.TestCase):
TEST_VOLUME[0],
TEST_VOLUME[1],
"available")
self.assertEqual(1, request.call_count)
self.assertEqual(2, request.call_count)
args, kwargs = request.call_args_list[1]
self.assertEqual(kwargs['json']['label'],
TEST_VOLUME[0]['id'].replace("-", ""))
def test_unmanage_snapshot(self):
"""The driver don't support unmange_snapshot."""

View File

@ -1,4 +1,4 @@
# Copyright (C) 2021, 2023, NEC corporation
# Copyright (C) 2021, 2024, NEC corporation
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -945,7 +945,10 @@ class VStorageRESTFCDriverTest(test.TestCase):
TEST_VOLUME[0],
TEST_VOLUME[1],
"available")
self.assertEqual(1, request.call_count)
self.assertEqual(2, request.call_count)
args, kwargs = request.call_args_list[1]
self.assertEqual(kwargs['json']['label'],
TEST_VOLUME[0]['id'].replace("-", ""))
def test_unmanage_snapshot(self):
"""The driver don't support unmange_snapshot."""

View File

@ -1,4 +1,4 @@
# Copyright (C) 2021, 2023, NEC corporation
# Copyright (C) 2021, 2024, NEC corporation
#
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -804,7 +804,10 @@ class VStorageRESTISCSIDriverTest(test.TestCase):
TEST_VOLUME[0],
TEST_VOLUME[1],
"available")
self.assertEqual(1, request.call_count)
self.assertEqual(2, request.call_count)
args, kwargs = request.call_args_list[1]
self.assertEqual(kwargs['json']['label'],
TEST_VOLUME[0]['id'].replace("-", ""))
def test_unmanage_snapshot(self):
"""The driver don't support unmange_snapshot."""

View File

@ -1,4 +1,4 @@
# Copyright (C) 2020, 2023, Hitachi, Ltd.
# Copyright (C) 2020, 2024, Hitachi, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -1102,6 +1102,13 @@ class HBSDCommon():
"""Migrate the specified volume."""
return False
def update_migrated_volume(self, volume, new_volume):
"""Update LDEV settings after generic volume migration."""
ldev = self.get_ldev(new_volume)
# We do not need to check if ldev is not None because it is guaranteed
# that ldev is not None because migration has been successful so far.
self.modify_ldev_name(ldev, volume['id'].replace("-", ""))
def retype(self, ctxt, volume, new_type, diff, host):
"""Retype the specified volume."""
return False

View File

@ -1,4 +1,4 @@
# Copyright (C) 2020, 2023, Hitachi, Ltd.
# Copyright (C) 2020, 2024, Hitachi, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -191,6 +191,7 @@ class HBSDFCDriver(driver.FibreChannelDriver):
self, ctxt, volume, new_volume, original_volume_status):
"""Do any remaining jobs after migration."""
self.common.discard_zero_page(new_volume)
self.common.update_migrated_volume(volume, new_volume)
super(HBSDFCDriver, self).update_migrated_volume(
ctxt, volume, new_volume, original_volume_status)

View File

@ -1,4 +1,4 @@
# Copyright (C) 2020, 2023, Hitachi, Ltd.
# Copyright (C) 2020, 2024, Hitachi, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -187,6 +187,7 @@ class HBSDISCSIDriver(driver.ISCSIDriver):
self, ctxt, volume, new_volume, original_volume_status):
"""Do any remaining jobs after migration."""
self.common.discard_zero_page(new_volume)
self.common.update_migrated_volume(volume, new_volume)
super(HBSDISCSIDriver, self).update_migrated_volume(
ctxt, volume, new_volume, original_volume_status)

View File

@ -1,4 +1,4 @@
# Copyright (C) 2022, 2023, Hitachi, Ltd.
# Copyright (C) 2022, 2024, Hitachi, Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
@ -940,6 +940,23 @@ class HBSDREPLICATION(rest.HBSDREST):
else:
return self.rep_primary.migrate_volume(volume, host)
def update_migrated_volume(self, volume, new_volume):
"""Update LDEV settings after generic volume migration."""
self._require_rep_primary()
ldev = self.rep_primary.get_ldev(new_volume)
# We do not need to check if ldev is not None because it is guaranteed
# that ldev is not None because migration has been successful so far.
if self._has_rep_pair(ldev):
self._require_rep_secondary()
thread = greenthread.spawn(
self.rep_secondary.update_migrated_volume, volume, new_volume)
try:
self.rep_primary.update_migrated_volume(volume, new_volume)
finally:
thread.wait()
else:
self.rep_primary.update_migrated_volume(volume, new_volume)
def _resync_rep_pair(self, pvol, svol):
copy_group_name = self._create_rep_copy_group_name(pvol)
rep_type = self.driver_info['mirror_attr']

View File

@ -0,0 +1,6 @@
fixes:
- |
Hitachi driver `bug #2071697
<https://bugs.launchpad.net/cinder/+bug/2071697>'_: Fix to set
correct object ID as LDEV nickname when running host-assisted
migration with ``retype`` or ``migration`` commands.