rbd.py (cinder-17.0.0) | : | rbd.py (cinder-17.0.1) | ||
---|---|---|---|---|
skipping to change at line 79 | skipping to change at line 79 | |||
default=False, | default=False, | |||
help='Flatten volumes created from snapshots to remove ' | help='Flatten volumes created from snapshots to remove ' | |||
'dependency from volume to snapshot'), | 'dependency from volume to snapshot'), | |||
cfg.StrOpt('rbd_secret_uuid', | cfg.StrOpt('rbd_secret_uuid', | |||
help='The libvirt uuid of the secret for the rbd_user ' | help='The libvirt uuid of the secret for the rbd_user ' | |||
'volumes'), | 'volumes'), | |||
cfg.IntOpt('rbd_max_clone_depth', | cfg.IntOpt('rbd_max_clone_depth', | |||
default=5, | default=5, | |||
help='Maximum number of nested volume clones that are ' | help='Maximum number of nested volume clones that are ' | |||
'taken before a flatten occurs. Set to 0 to disable ' | 'taken before a flatten occurs. Set to 0 to disable ' | |||
'cloning.'), | 'cloning. Note: lowering this value will not affect ' | |||
'existing volumes whose clone depth exceeds the new ' | ||||
'value.'), | ||||
cfg.IntOpt('rbd_store_chunk_size', default=4, | cfg.IntOpt('rbd_store_chunk_size', default=4, | |||
help='Volumes will be chunked into objects of this size ' | help='Volumes will be chunked into objects of this size ' | |||
'(in megabytes).'), | '(in megabytes).'), | |||
cfg.IntOpt('rados_connect_timeout', default=-1, | cfg.IntOpt('rados_connect_timeout', default=-1, | |||
help='Timeout value (in seconds) used when connecting to ' | help='Timeout value (in seconds) used when connecting to ' | |||
'ceph cluster. If value < 0, no timeout is set and ' | 'ceph cluster. If value < 0, no timeout is set and ' | |||
'default librados value is used.'), | 'default librados value is used.'), | |||
cfg.IntOpt('rados_connection_retries', default=3, | cfg.IntOpt('rados_connection_retries', default=3, | |||
help='Number of retries if connection to ceph cluster ' | help='Number of retries if connection to ceph cluster ' | |||
'failed.'), | 'failed.'), | |||
skipping to change at line 655 | skipping to change at line 657 | |||
parent_volume = self.rbd.Image(client.ioctx, volume_name) | parent_volume = self.rbd.Image(client.ioctx, volume_name) | |||
try: | try: | |||
_pool, parent, _snap = self._get_clone_info(parent_volume, | _pool, parent, _snap = self._get_clone_info(parent_volume, | |||
volume_name) | volume_name) | |||
finally: | finally: | |||
parent_volume.close() | parent_volume.close() | |||
if not parent: | if not parent: | |||
return depth | return depth | |||
# If clone depth was reached, flatten should have occurred so if it has | ||||
# been exceeded then something has gone wrong. | ||||
if depth > self.configuration.rbd_max_clone_depth: | ||||
raise Exception(_("clone depth exceeds limit of %s") % | ||||
(self.configuration.rbd_max_clone_depth)) | ||||
return self._get_clone_depth(client, parent, depth + 1) | return self._get_clone_depth(client, parent, depth + 1) | |||
def _extend_if_required(self, volume, src_vref): | def _extend_if_required(self, volume, src_vref): | |||
"""Extends a volume if required | """Extends a volume if required | |||
In case src_vref size is smaller than the size if the requested | In case src_vref size is smaller than the size if the requested | |||
new volume call _resize(). | new volume call _resize(). | |||
""" | """ | |||
if volume.size != src_vref.size: | if volume.size != src_vref.size: | |||
LOG.debug("resize volume '%(dst_vol)s' from %(src_size)d to " | LOG.debug("resize volume '%(dst_vol)s' from %(src_size)d to " | |||
skipping to change at line 730 | skipping to change at line 726 | |||
{'src_vol': src_name, | {'src_vol': src_name, | |||
'src_snap': clone_snap, | 'src_snap': clone_snap, | |||
'dest': dest_name, | 'dest': dest_name, | |||
'error': e}) | 'error': e}) | |||
LOG.exception(msg) | LOG.exception(msg) | |||
raise exception.VolumeBackendAPIException(data=msg) | raise exception.VolumeBackendAPIException(data=msg) | |||
depth = self._get_clone_depth(client, src_name) | depth = self._get_clone_depth(client, src_name) | |||
# If dest volume is a clone and rbd_max_clone_depth reached, | # If dest volume is a clone and rbd_max_clone_depth reached, | |||
# flatten the dest after cloning. Zero rbd_max_clone_depth means | # flatten the dest after cloning. Zero rbd_max_clone_depth means | |||
# infinite is allowed. | # volumes are always flattened. | |||
if depth >= self.configuration.rbd_max_clone_depth: | if depth >= self.configuration.rbd_max_clone_depth: | |||
LOG.info("maximum clone depth (%d) has been reached - " | LOG.info("maximum clone depth (%d) has been reached - " | |||
"flattening dest volume", | "flattening dest volume", | |||
self.configuration.rbd_max_clone_depth) | self.configuration.rbd_max_clone_depth) | |||
dest_volume = self.rbd.Image(client.ioctx, dest_name) | ||||
# Flatten destination volume | ||||
try: | try: | |||
# Flatten destination volume | with RBDVolumeProxy(self, dest_name, client=client, | |||
LOG.debug("flattening dest volume %s", dest_name) | ioctx=client.ioctx) as dest_volume: | |||
dest_volume.flatten() | LOG.debug("flattening dest volume %s", dest_name) | |||
dest_volume.flatten() | ||||
except Exception as e: | except Exception as e: | |||
msg = (_("Failed to flatten volume %(volume)s with " | msg = (_("Failed to flatten volume %(volume)s with " | |||
"error: %(error)s.") % | "error: %(error)s.") % | |||
{'volume': dest_name, | {'volume': dest_name, | |||
'error': e}) | 'error': e}) | |||
LOG.exception(msg) | LOG.exception(msg) | |||
src_volume.close() | src_volume.close() | |||
raise exception.VolumeBackendAPIException(data=msg) | raise exception.VolumeBackendAPIException(data=msg) | |||
finally: | ||||
dest_volume.close() | ||||
try: | try: | |||
# remove temporary snap | # remove temporary snap | |||
LOG.debug("remove temporary snap %s", clone_snap) | LOG.debug("remove temporary snap %s", clone_snap) | |||
src_volume.unprotect_snap(clone_snap) | src_volume.unprotect_snap(clone_snap) | |||
src_volume.remove_snap(clone_snap) | src_volume.remove_snap(clone_snap) | |||
except Exception as e: | except Exception as e: | |||
msg = (_("Failed to remove temporary snap " | msg = (_("Failed to remove temporary snap " | |||
"%(snap_name)s, error: %(error)s") % | "%(snap_name)s, error: %(error)s") % | |||
{'snap_name': clone_snap, | {'snap_name': clone_snap, | |||
End of changes. 6 change blocks. | ||||
14 lines changed or deleted | 10 lines changed or added |