diff --git a/kloudbuster/base_network.py b/kloudbuster/base_network.py index dbf177f..4bd744f 100644 --- a/kloudbuster/base_network.py +++ b/kloudbuster/base_network.py @@ -173,6 +173,12 @@ class BaseNetwork(): bs_obj = base_storage.BaseStorage(self.cinder_client) vol_size = config_scale['storage_stage_configs']['disk_size'] 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: vol_size = 0 @@ -186,11 +192,8 @@ class BaseNetwork(): # Don't create volumn for KB-Proxy if vol_size and instance_count < vm_total - 1: vol_name = network_prefix + "-V" + str(instance_count) - if volume_type: - perf_instance.vol = bs_obj.create_vol(vol_size, name=vol_name, - type=volume_type) - else: - perf_instance.vol = bs_obj.create_vol(vol_size, name=vol_name) + perf_instance.vol = bs_obj.create_vol(vol_size, vol_timeout, name=vol_name, + type=volume_type) self.res_logger.log('volumes', vol_name, perf_instance.vol.id) perf_instance.subnet_ip = self.network['subnet_ip'] diff --git a/kloudbuster/base_storage.py b/kloudbuster/base_storage.py index 6e3af1c..bcd7acc 100644 --- a/kloudbuster/base_storage.py +++ b/kloudbuster/base_storage.py @@ -29,19 +29,25 @@ class BaseStorage(): def __init__(self, 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: vol = self.cinderclient.volumes.create(size, name=name, volume_type=type) else: vol = self.cinderclient.volumes.create(size, name=name) - for _ in range(10): + + start_t = time.time() + while (True): if vol.status == 'creating': - time.sleep(1) + time.sleep(5) elif vol.status == 'available': break elif vol.status == 'error': 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) return vol diff --git a/kloudbuster/cfg.scale.yaml b/kloudbuster/cfg.scale.yaml index fdb8ef1..a415afb 100644 --- a/kloudbuster/cfg.scale.yaml +++ b/kloudbuster/cfg.scale.yaml @@ -323,6 +323,8 @@ client: # Make sure volume type is public # If an invalid volume type is specified tool will Error out on volume create # volume_type: cephtype + # Volume creation timeout value specified in sec + vol_create_timeout_sec: 150 # Storage tool specific configs (per VM)