Skip to content

Commit

Permalink
Speed up second call to extend
Browse files Browse the repository at this point in the history
Re-running a task that extends a volume is slow on the consumer side
call because we call os-brick's extend method unconditionally.

This patch changes this behavior and will only call os-brick if the
volumes has not already been extended, thus improving the speed of a
second call to extend a volume that has already been extended an the new
size is already known in the system.
  • Loading branch information
Akrog committed Sep 13, 2019
1 parent 908aea2 commit cc63415
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
1 change: 1 addition & 0 deletions action_plugins/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ def extended(self, args):
# We cannot pass the size or the node won't find the attachment
pass_args.pop('size')
pass_args.pop('old_size', None)
pass_args['new_size'] = result['new_size']
pass_args['provider'] = self.provider_name
# pass_args.update(result[STORAGE_DATA])
result = self.runner(pass_args, ctrl=False)
Expand Down
40 changes: 23 additions & 17 deletions library/cinderlib_storage_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ def _validate_volume(module):
if module.params.get('state') == 'connected':
specs[common.CONNECTION_INFO] = {'type': 'dict', 'required': True}

if module.params.get('state') == 'extended':
specs['new_size'] = {'type': 'int', 'required': True}

new_module = basic.AnsibleModule(specs, check_invalid_arguments=True)
return new_module

Expand Down Expand Up @@ -400,23 +403,26 @@ def extend_volume(db, module):
data = _get_data(db, module)
if not data:
module.fail_json(msg='No attachment found')
old_size = _get_size(db, module)
connector_dict = data['connector']
conn_info = data[common.CONNECTION_INFO]
protocol = conn_info['driver_volume_type']
# NOTE(geguileo): afaik only remotefs uses connection info
conn = connector.InitiatorConnector.factory(
protocol, 'sudo', user_multipath=connector_dict['multipath'],
device_scan_attempts=3, conn=connector_dict)
new_size = conn.extend_volume(conn_info['data'])
# Extend returns the size in bytes, convert to GB
new_size = int(round(new_size / 1024.0 / 1024.0 / 1024.0))

# Need to update the entry in the database or next connect/disconnect
# requests will not find it
_update_attachment_size(db, conn_info['data']['volume_id'], new_size)

return {'changed': old_size != new_size,
our_size = _get_size(db, module)
new_size = module.params['new_size']

if our_size != new_size:
connector_dict = data['connector']
conn_info = data[common.CONNECTION_INFO]
protocol = conn_info['driver_volume_type']
# NOTE(geguileo): afaik only remotefs uses connection info
conn = connector.InitiatorConnector.factory(
protocol, 'sudo', user_multipath=connector_dict['multipath'],
device_scan_attempts=3, conn=connector_dict)
new_size = conn.extend_volume(conn_info['data'])
# Extend returns the size in bytes, convert to GB
new_size = int(round(new_size / 1024.0 / 1024.0 / 1024.0))

# Need to update the entry in the database or next connect/disconnect
# requests will not find it
_update_attachment_size(db, conn_info['data']['volume_id'], new_size)

return {'changed': our_size != new_size,
'size': new_size,
'device': data['device']}

Expand Down

0 comments on commit cc63415

Please sign in to comment.