Provides mount point as cinder requires it to attach volume

This patch provides a mount point which is required by cinder to
attach the volume to the baremetal, when the volume targets are
created for any node.

Story: 2004864
Task: 29107

Change-Id: Id2a2e071026b86a6fd586a998bf865b1ddb960d7
This commit is contained in:
mvpnitesh 2019-01-28 09:12:21 +00:00 committed by Julia Kreger
parent 4271f92f24
commit 57037378be
3 changed files with 21 additions and 10 deletions

View File

@ -307,10 +307,10 @@ def attach_volumes(task, volume_list, connector):
# database record to indicate that the attachment has # database record to indicate that the attachment has
# been completed, which moves the volume to the # been completed, which moves the volume to the
# 'attached' state. This action also sets a mountpoint # 'attached' state. This action also sets a mountpoint
# for the volume, if known. In our use case, there is # for the volume, as cinder requires a mointpoint to
# no way for us to know what the mountpoint is inside of # attach the volume, thus we send 'mount_volume'.
# the operating system, thus we send None. client.volumes.attach(volume_id, instance_uuid,
client.volumes.attach(volume_id, instance_uuid, None) 'ironic_mountpoint')
except cinder_exceptions.ClientException as e: except cinder_exceptions.ClientException as e:
msg = (_('Failed to inform cinder that the attachment for volume ' msg = (_('Failed to inform cinder that the attachment for volume '

View File

@ -195,6 +195,7 @@ class TestCinderActions(db_base.DbTestCase):
self.node = object_utils.create_test_node( self.node = object_utils.create_test_node(
self.context, self.context,
instance_uuid=uuidutils.generate_uuid()) instance_uuid=uuidutils.generate_uuid())
self.mount_point = 'ironic_mountpoint'
@mock.patch.object(cinderclient.volumes.VolumeManager, 'attach', @mock.patch.object(cinderclient.volumes.VolumeManager, 'attach',
autospec=True) autospec=True)
@ -239,7 +240,8 @@ class TestCinderActions(db_base.DbTestCase):
mock_reserve.assert_called_once_with(mock.ANY, volume_id) mock_reserve.assert_called_once_with(mock.ANY, volume_id)
mock_init.assert_called_once_with(mock.ANY, volume_id, connector) mock_init.assert_called_once_with(mock.ANY, volume_id, connector)
mock_attach.assert_called_once_with(mock.ANY, volume_id, mock_attach.assert_called_once_with(mock.ANY, volume_id,
self.node.instance_uuid, None) self.node.instance_uuid,
self.mount_point)
mock_set_meta.assert_called_once_with(mock.ANY, volume_id, mock_set_meta.assert_called_once_with(mock.ANY, volume_id,
{'bar': 'baz'}) {'bar': 'baz'})
mock_get.assert_called_once_with(mock.ANY, volume_id) mock_get.assert_called_once_with(mock.ANY, volume_id)
@ -271,7 +273,6 @@ class TestCinderActions(db_base.DbTestCase):
'ironic_volume_uuid': '000-001'}}] 'ironic_volume_uuid': '000-001'}}]
volumes = [volume_id, 'already_attached'] volumes = [volume_id, 'already_attached']
connector = {'foo': 'bar'} connector = {'foo': 'bar'}
mock_create_meta.return_value = {'bar': 'baz'} mock_create_meta.return_value = {'bar': 'baz'}
mock_get.side_effect = [ mock_get.side_effect = [
@ -294,7 +295,8 @@ class TestCinderActions(db_base.DbTestCase):
mock_reserve.assert_called_once_with(mock.ANY, volume_id) mock_reserve.assert_called_once_with(mock.ANY, volume_id)
mock_init.assert_called_once_with(mock.ANY, volume_id, connector) mock_init.assert_called_once_with(mock.ANY, volume_id, connector)
mock_attach.assert_called_once_with(mock.ANY, volume_id, mock_attach.assert_called_once_with(mock.ANY, volume_id,
self.node.instance_uuid, None) self.node.instance_uuid,
self.mount_point)
mock_set_meta.assert_called_once_with(mock.ANY, volume_id, mock_set_meta.assert_called_once_with(mock.ANY, volume_id,
{'bar': 'baz'}) {'bar': 'baz'})
@ -355,7 +357,7 @@ class TestCinderActions(db_base.DbTestCase):
mock.ANY, '111111111-0000-0000-0000-000000000003', connector) mock.ANY, '111111111-0000-0000-0000-000000000003', connector)
mock_attach.assert_called_once_with( mock_attach.assert_called_once_with(
mock.ANY, '111111111-0000-0000-0000-000000000003', mock.ANY, '111111111-0000-0000-0000-000000000003',
self.node.instance_uuid, None) self.node.instance_uuid, self.mount_point)
mock_set_meta.assert_called_once_with( mock_set_meta.assert_called_once_with(
mock.ANY, '111111111-0000-0000-0000-000000000003', {'bar': 'baz'}) mock.ANY, '111111111-0000-0000-0000-000000000003', {'bar': 'baz'})
@ -446,7 +448,8 @@ class TestCinderActions(db_base.DbTestCase):
mock_reserve.assert_called_once_with(mock.ANY, volume_id) mock_reserve.assert_called_once_with(mock.ANY, volume_id)
mock_init.assert_called_once_with(mock.ANY, volume_id, connector) mock_init.assert_called_once_with(mock.ANY, volume_id, connector)
mock_attach.assert_called_once_with(mock.ANY, volume_id, mock_attach.assert_called_once_with(mock.ANY, volume_id,
self.node.instance_uuid, None) self.node.instance_uuid,
self.mount_point)
mock_get.assert_called_once_with(mock.ANY, volume_id) mock_get.assert_called_once_with(mock.ANY, volume_id)
mock_is_attached.assert_called_once_with(mock.ANY, mock_is_attached.assert_called_once_with(mock.ANY,
mock_get.return_value) mock_get.return_value)
@ -496,7 +499,8 @@ class TestCinderActions(db_base.DbTestCase):
mock_reserve.assert_called_once_with(mock.ANY, volume_id) mock_reserve.assert_called_once_with(mock.ANY, volume_id)
mock_init.assert_called_once_with(mock.ANY, volume_id, connector) mock_init.assert_called_once_with(mock.ANY, volume_id, connector)
mock_attach.assert_called_once_with(mock.ANY, volume_id, mock_attach.assert_called_once_with(mock.ANY, volume_id,
self.node.instance_uuid, None) self.node.instance_uuid,
self.mount_point)
mock_set_meta.assert_called_once_with(mock.ANY, volume_id, mock_set_meta.assert_called_once_with(mock.ANY, volume_id,
{'bar': 'baz'}) {'bar': 'baz'})
mock_get.assert_called_once_with(mock.ANY, volume_id) mock_get.assert_called_once_with(mock.ANY, volume_id)

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes a bug where cinder block storage service volumes volume fail to attach expecting a
mountpoint to be a valid string. See `story 2004864
<https://storyboard.openstack.org/#!/story/2004864>`_ for additional
information.