Added counter for volume creation

Change-Id: I56b3a5866968891785d4dc85d6276a998c81ff2a
This commit is contained in:
rbalasun 2020-08-06 18:15:40 -07:00
parent ee744e7ca7
commit cf0219961b
3 changed files with 19 additions and 8 deletions

View File

@ -173,6 +173,12 @@ class BaseNetwork():
bs_obj = base_storage.BaseStorage(self.cinder_client) bs_obj = base_storage.BaseStorage(self.cinder_client)
vol_size = config_scale['storage_stage_configs']['disk_size'] vol_size = config_scale['storage_stage_configs']['disk_size']
volume_type = config_scale['storage_stage_configs'].get('volume_type', None) volume_type = config_scale['storage_stage_configs'].get('volume_type', None)
DEFAULT_VOL_CREATE_TIMEOUT_SEC = 150
try:
vol_timeout = int(config_scale['storage_stage_configs'].get('vol_create_timeout_sec', DEFAULT_VOL_CREATE_TIMEOUT_SEC))
except ValueError:
vol_timeout = DEFAULT_VOL_CREATE_TIMEOUT_SEC
LOG.info("Incorrect input for vol_create_timeout_sec in cfg file ,proceeding with default timeout %d" % vol_timeout)
else: else:
vol_size = 0 vol_size = 0
@ -186,11 +192,8 @@ class BaseNetwork():
# Don't create volumn for KB-Proxy # Don't create volumn for KB-Proxy
if vol_size and instance_count < vm_total - 1: if vol_size and instance_count < vm_total - 1:
vol_name = network_prefix + "-V" + str(instance_count) vol_name = network_prefix + "-V" + str(instance_count)
if volume_type: perf_instance.vol = bs_obj.create_vol(vol_size, vol_timeout, name=vol_name,
perf_instance.vol = bs_obj.create_vol(vol_size, name=vol_name, type=volume_type)
type=volume_type)
else:
perf_instance.vol = bs_obj.create_vol(vol_size, name=vol_name)
self.res_logger.log('volumes', vol_name, perf_instance.vol.id) self.res_logger.log('volumes', vol_name, perf_instance.vol.id)
perf_instance.subnet_ip = self.network['subnet_ip'] perf_instance.subnet_ip = self.network['subnet_ip']

View File

@ -29,19 +29,25 @@ class BaseStorage():
def __init__(self, cinderclient): def __init__(self, cinderclient):
self.cinderclient = cinderclient self.cinderclient = cinderclient
def create_vol(self, size, name=None, type=None): def create_vol(self, size, vol_timeout, name=None, type=None):
if type: if type:
vol = self.cinderclient.volumes.create(size, name=name, vol = self.cinderclient.volumes.create(size, name=name,
volume_type=type) volume_type=type)
else: else:
vol = self.cinderclient.volumes.create(size, name=name) vol = self.cinderclient.volumes.create(size, name=name)
for _ in range(10):
start_t = time.time()
while (True):
if vol.status == 'creating': if vol.status == 'creating':
time.sleep(1) time.sleep(5)
elif vol.status == 'available': elif vol.status == 'available':
break break
elif vol.status == 'error': elif vol.status == 'error':
raise KBVolCreationException('Not enough disk space in the host?') raise KBVolCreationException('Not enough disk space in the host?')
if (time.time() - start_t) > vol_timeout:
raise KBVolCreationException('Volume creation timed out')
break
vol = self.cinderclient.volumes.get(vol.id) vol = self.cinderclient.volumes.get(vol.id)
return vol return vol

View File

@ -323,6 +323,8 @@ client:
# Make sure volume type is public # Make sure volume type is public
# If an invalid volume type is specified tool will Error out on volume create # If an invalid volume type is specified tool will Error out on volume create
# volume_type: cephtype # volume_type: cephtype
# Volume creation timeout value specified in sec
vol_create_timeout_sec: 150
# Storage tool specific configs (per VM) # Storage tool specific configs (per VM)