def cluster_upgrade(cortx_conf_url: str, force_override: bool = False): """ Description: Upgrades Cluster Components 1. Reads Cortx Config and obtain cluster components 2. Invoke upgrade phase of cluster components Paramaters: [IN] CORTX Config URL """ cortx_conf = MappedConf(cortx_conf_url) apply_phase = ProvisionerStages.UPGRADE.value node_id, node_name = CortxProvisioner._get_node_info(cortx_conf) is_valid, ret_code = CortxProvisioner._validate_provisioning_status( cortx_conf, node_id, apply_phase) if is_valid is False: if force_override is False: Log.warn('Validation check failed, Aborting upgrade with ' f'return code {ret_code}.') return ret_code else: Log.info( 'Validation check failed, Forcefully overriding upgrade.') Log.info(f"Starting cluster upgrade on {node_id}:{node_name}") CortxProvisioner._update_provisioning_status(cortx_conf, node_id, apply_phase) CortxProvisioner._provision_components(cortx_conf, UpgradeInterfaces, apply_phase) # Update CORTX version, once the upgrade is successful CortxProvisioner._add_version_info(cortx_conf, node_id) CortxProvisioner._update_provisioning_status( cortx_conf, node_id, apply_phase, ProvisionerStatus.SUCCESS.value) Log.info(f"Finished cluster upgrade on {node_id}:{node_name}")
def cluster_deploy(cortx_conf_url: str, force_override: bool = False): """ Description: Configures Cluster Components 1. Reads Cortx Config and obtain cluster components 2. Invoke Mini Provisioners of cluster components Paramaters: [IN] CORTX Config URL """ apply_phase = ProvisionerStages.DEPLOYMENT.value node_id, node_name = CortxProvisioner._get_node_info(CortxProvisioner._conf_index) is_valid, ret_code = CortxProvisioner._validate_provisioning_status( CortxProvisioner._conf_index, node_id, apply_phase) if is_valid is False: if force_override is False: Log.warn('Validation check failed, Aborting cluster bootstarp' f' with return code {ret_code}') return ret_code else: Log.info('Validation check failed, Forcefully overriding deployment.') Log.info(f"Starting cluster bootstrap on {node_id}:{node_name}") CortxProvisioner._update_provisioning_status( CortxProvisioner._conf_index, node_id, apply_phase) CortxProvisioner._provision_components(cortx_conf_url, CortxProvisioner._conf_index, DeploymentInterfaces, apply_phase) CortxProvisioner._add_version_info(CortxProvisioner._conf_index, node_id) CortxProvisioner._update_provisioning_status( CortxProvisioner._conf_index, node_id, apply_phase, ProvisionerStatus.SUCCESS.value) Log.info(f"Finished cluster bootstrap on {node_id}:{node_name}")
def save(self, cortx_conf, cortx_solution_config): """Save cortx-config into confstore""" try: cortx_solution_config_keys = filter( lambda x: x.startswith('cortx'), Conf.get_keys(cortx_solution_config)) cortx_conf.copy(cortx_solution_config, cortx_solution_config_keys) # Change environment_type to setup_type # TODO: remove this code once setup_type key is deleted. cortx_conf.set('cortx>common>setup_type', cortx_conf.get('cortx>common>environment_type')) cortx_conf.delete('cortx>common>environment_type') # Check for release key. release_spec = self._cortx_solution_config.get('common').get( 'release') is_valid, release_info = self._cortx_release.validate(release_spec) if is_valid is False: for key in release_info.keys(): release_key_path = f'cortx>common>release>{key}' Log.warn( f'Release key {release_key_path} is missing or has ' 'incorrect value.') Log.info(f'Adding key "{release_key_path}" ' f'and value "{release_info[key]}" in confstore.') cortx_conf.set(release_key_path, release_info[key]) except KeyError as e: raise CortxProvisionerError( errno.EINVAL, f'Error occurred while adding CORTX config information into confstore {e}' )
def cluster_upgrade(cortx_conf_url: str, force_override: bool = False): """ Description: Upgrades Cluster Components 1. Reads Cortx Config and obtain cluster components 2. Invoke upgrade phase of cluster components Paramaters: [IN] CORTX Config URL """ # query to get cluster health upgrade_mode = os.getenv(const.UPGRADE_MODE_KEY, const.UPGRADE_MODE_VAL).upper() if upgrade_mode != "COLD" and not CortxProvisioner.is_cluster_healthy(): Log.error('Cluster is unhealthy, Aborting upgrade with return code 1') return 1 apply_phase = ProvisionerStages.UPGRADE.value node_id, node_name = CortxProvisioner._get_node_info(CortxProvisioner._conf_index) is_valid, ret_code = CortxProvisioner._validate_provisioning_status( CortxProvisioner._conf_index, node_id, apply_phase) if is_valid is False: if force_override is False: Log.warn('Validation check failed, Aborting upgrade with ' f'return code {ret_code}.') return ret_code else: Log.info('Validation check failed, Forcefully overriding upgrade.') Log.info(f"Starting cluster upgrade on {node_id}:{node_name}") CortxProvisioner._update_provisioning_status( CortxProvisioner._conf_index, node_id, apply_phase) CortxProvisioner._provision_components(cortx_conf_url, CortxProvisioner._conf_index, UpgradeInterfaces, apply_phase) # Update CORTX version, once the upgrade is successful CortxProvisioner._add_version_info(CortxProvisioner._conf_index, node_id) CortxProvisioner._update_provisioning_status( CortxProvisioner._conf_index, node_id, apply_phase, ProvisionerStatus.SUCCESS.value) Log.info(f"Finished cluster upgrade on {node_id}:{node_name}")