@@ -6781,102 +6781,102 @@ def set_up_azure_container_storage(self, mc: ManagedCluster) -> ManagedCluster:
67816781 if self .context .raw_param .get ("enable_azure_container_storage" ) is not None :
67826782 self .context .set_intermediate ("enable_azure_container_storage" , True , overwrite_exists = True )
67836783 container_storage_version = self .context .raw_param .get ("container_storage_version" )
6784- if container_storage_version is not None :
6785- if container_storage_version == CONST_ACSTOR_VERSION_V1 :
6786- # read the azure container storage values passed
6787- pool_type = self .context .raw_param .get ("enable_azure_container_storage" )
6788- enable_azure_container_storage = pool_type is not None
6789- ephemeral_disk_volume_type = self .context .raw_param .get ("ephemeral_disk_volume_type" )
6790- ephemeral_disk_nvme_perf_tier = self .context .raw_param .get ("ephemeral_disk_nvme_perf_tier" )
6791- if (ephemeral_disk_volume_type is not None or ephemeral_disk_nvme_perf_tier is not None ) and \
6792- not enable_azure_container_storage :
6793- params_defined_arr = []
6794- if ephemeral_disk_volume_type is not None :
6795- params_defined_arr .append ('--ephemeral-disk-volume-type' )
6796- if ephemeral_disk_nvme_perf_tier is not None :
6797- params_defined_arr .append ('--ephemeral-disk-nvme-perf-tier' )
6798-
6799- params_defined = 'and ' .join (params_defined_arr )
6800- raise RequiredArgumentMissingError (
6801- f'Cannot set { params_defined } without the parameter --enable-azure-container-storage.'
6802- )
68036784
6804- if enable_azure_container_storage :
6805- pool_name = self .context .raw_param .get ("storage_pool_name" )
6806- pool_option = self .context .raw_param .get ("storage_pool_option" )
6807- pool_sku = self .context .raw_param .get ("storage_pool_sku" )
6808- pool_size = self .context .raw_param .get ("storage_pool_size" )
6809- if not mc .agent_pool_profiles :
6810- raise UnknownError ("Encountered an unexpected error while getting the agent pools from the cluster." )
6811- agentpool = mc .agent_pool_profiles [0 ]
6812- agentpool_details = {}
6813- pool_details = {}
6814- pool_details ["vm_size" ] = agentpool .vm_size
6815- pool_details ["count" ] = agentpool .count
6816- pool_details ["os_type" ] = agentpool .os_type
6817- pool_details ["mode" ] = agentpool .mode
6818- pool_details ["node_taints" ] = agentpool .node_taints
6819- pool_details ["zoned" ] = agentpool .availability_zones is not None
6820- agentpool_details [agentpool .name ] = pool_details
6821- # Marking the only agentpool name as the valid nodepool for
6822- # installing Azure Container Storage during `az aks create`
6823- nodepool_list = agentpool .name
6785+ if container_storage_version is not None and container_storage_version == CONST_ACSTOR_VERSION_V1 :
6786+ # read the azure container storage values passed
6787+ pool_type = self .context .raw_param .get ("enable_azure_container_storage" )
6788+ enable_azure_container_storage = pool_type is not None
6789+ ephemeral_disk_volume_type = self .context .raw_param .get ("ephemeral_disk_volume_type" )
6790+ ephemeral_disk_nvme_perf_tier = self .context .raw_param .get ("ephemeral_disk_nvme_perf_tier" )
6791+ if (ephemeral_disk_volume_type is not None or ephemeral_disk_nvme_perf_tier is not None ) and \
6792+ not enable_azure_container_storage :
6793+ params_defined_arr = []
6794+ if ephemeral_disk_volume_type is not None :
6795+ params_defined_arr .append ('--ephemeral-disk-volume-type' )
6796+ if ephemeral_disk_nvme_perf_tier is not None :
6797+ params_defined_arr .append ('--ephemeral-disk-nvme-perf-tier' )
68246798
6825- from azure .cli .command_modules .acs .azurecontainerstorage ._validators import (
6826- validate_enable_azure_container_storage_v1_params
6827- )
6828- from azure .cli .command_modules .acs .azurecontainerstorage ._consts import (
6829- CONST_ACSTOR_IO_ENGINE_LABEL_KEY ,
6830- CONST_ACSTOR_IO_ENGINE_LABEL_VAL ,
6831- CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY ,
6832- CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD ,
6833- )
6834- from azure .cli .command_modules .acs .azurecontainerstorage ._helpers import generate_vm_sku_cache_for_region
6835- generate_vm_sku_cache_for_region (self .cmd .cli_ctx , self .context .get_location ())
6836-
6837- default_ephemeral_disk_volume_type = CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY
6838- default_ephemeral_disk_nvme_perf_tier = CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD
6839- validate_enable_azure_container_storage_v1_params (
6840- pool_type ,
6841- pool_name ,
6842- pool_sku ,
6843- pool_option ,
6844- pool_size ,
6845- nodepool_list ,
6846- agentpool_details ,
6847- False ,
6848- False ,
6849- "" ,
6850- False ,
6851- False ,
6852- False ,
6853- False ,
6854- ephemeral_disk_volume_type ,
6855- ephemeral_disk_nvme_perf_tier ,
6856- default_ephemeral_disk_volume_type ,
6857- default_ephemeral_disk_nvme_perf_tier ,
6858- )
6799+ params_defined = 'and ' .join (params_defined_arr )
6800+ raise RequiredArgumentMissingError (
6801+ f'Cannot set { params_defined } without the parameter --enable-azure-container-storage.'
6802+ )
68596803
6860- # Setup Azure Container Storage labels on the nodepool
6861- nodepool_labels = agentpool .node_labels
6862- if nodepool_labels is None :
6863- nodepool_labels = {}
6864- nodepool_labels [CONST_ACSTOR_IO_ENGINE_LABEL_KEY ] = CONST_ACSTOR_IO_ENGINE_LABEL_VAL
6865- agentpool .node_labels = nodepool_labels
6866-
6867- # set intermediates
6868- self .context .set_intermediate ("container_storage_version" , container_storage_version , overwrite_exists = True )
6869- self .context .set_intermediate ("azure_container_storage_nodepools" , nodepool_list , overwrite_exists = True )
6870- self .context .set_intermediate (
6871- "current_ephemeral_nvme_perf_tier" ,
6872- default_ephemeral_disk_nvme_perf_tier ,
6873- overwrite_exists = True
6874- )
6875- self .context .set_intermediate (
6876- "existing_ephemeral_disk_volume_type" ,
6877- default_ephemeral_disk_volume_type ,
6878- overwrite_exists = True
6879- )
6804+ if enable_azure_container_storage :
6805+ pool_name = self .context .raw_param .get ("storage_pool_name" )
6806+ pool_option = self .context .raw_param .get ("storage_pool_option" )
6807+ pool_sku = self .context .raw_param .get ("storage_pool_sku" )
6808+ pool_size = self .context .raw_param .get ("storage_pool_size" )
6809+ if not mc .agent_pool_profiles :
6810+ raise UnknownError ("Encountered an unexpected error while getting the agent pools from the cluster." )
6811+ agentpool = mc .agent_pool_profiles [0 ]
6812+ agentpool_details = {}
6813+ pool_details = {}
6814+ pool_details ["vm_size" ] = agentpool .vm_size
6815+ pool_details ["count" ] = agentpool .count
6816+ pool_details ["os_type" ] = agentpool .os_type
6817+ pool_details ["mode" ] = agentpool .mode
6818+ pool_details ["node_taints" ] = agentpool .node_taints
6819+ pool_details ["zoned" ] = agentpool .availability_zones is not None
6820+ agentpool_details [agentpool .name ] = pool_details
6821+ # Marking the only agentpool name as the valid nodepool for
6822+ # installing Azure Container Storage during `az aks create`
6823+ nodepool_list = agentpool .name
6824+
6825+ from azure .cli .command_modules .acs .azurecontainerstorage ._validators import (
6826+ validate_enable_azure_container_storage_v1_params
6827+ )
6828+ from azure .cli .command_modules .acs .azurecontainerstorage ._consts import (
6829+ CONST_ACSTOR_IO_ENGINE_LABEL_KEY ,
6830+ CONST_ACSTOR_IO_ENGINE_LABEL_VAL ,
6831+ CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY ,
6832+ CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD ,
6833+ )
6834+ from azure .cli .command_modules .acs .azurecontainerstorage ._helpers import generate_vm_sku_cache_for_region
6835+ generate_vm_sku_cache_for_region (self .cmd .cli_ctx , self .context .get_location ())
6836+
6837+ default_ephemeral_disk_volume_type = CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY
6838+ default_ephemeral_disk_nvme_perf_tier = CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD
6839+ validate_enable_azure_container_storage_v1_params (
6840+ pool_type ,
6841+ pool_name ,
6842+ pool_sku ,
6843+ pool_option ,
6844+ pool_size ,
6845+ nodepool_list ,
6846+ agentpool_details ,
6847+ False ,
6848+ False ,
6849+ "" ,
6850+ False ,
6851+ False ,
6852+ False ,
6853+ False ,
6854+ ephemeral_disk_volume_type ,
6855+ ephemeral_disk_nvme_perf_tier ,
6856+ default_ephemeral_disk_volume_type ,
6857+ default_ephemeral_disk_nvme_perf_tier ,
6858+ )
6859+
6860+ # Setup Azure Container Storage labels on the nodepool
6861+ nodepool_labels = agentpool .node_labels
6862+ if nodepool_labels is None :
6863+ nodepool_labels = {}
6864+ nodepool_labels [CONST_ACSTOR_IO_ENGINE_LABEL_KEY ] = CONST_ACSTOR_IO_ENGINE_LABEL_VAL
6865+ agentpool .node_labels = nodepool_labels
6866+
6867+ # set intermediates
6868+ self .context .set_intermediate ("container_storage_version" , container_storage_version , overwrite_exists = True )
6869+ self .context .set_intermediate ("azure_container_storage_nodepools" , nodepool_list , overwrite_exists = True )
6870+ self .context .set_intermediate (
6871+ "current_ephemeral_nvme_perf_tier" ,
6872+ default_ephemeral_disk_nvme_perf_tier ,
6873+ overwrite_exists = True
6874+ )
6875+ self .context .set_intermediate (
6876+ "existing_ephemeral_disk_volume_type" ,
6877+ default_ephemeral_disk_volume_type ,
6878+ overwrite_exists = True
6879+ )
68806880 else :
68816881 enable_azure_container_storage = self .context .raw_param .get ("enable_azure_container_storage" )
68826882 storage_pool_name = self .context .raw_param .get ("storage_pool_name" )
@@ -8800,8 +8800,15 @@ def update_azure_container_storage(self, mc: ManagedCluster) -> ManagedCluster:
88008800 # check if we are trying to enable container storage v1
88018801 enable_azure_container_storage_param = self .context .raw_param .get ("enable_azure_container_storage" )
88028802 disable_azure_container_storage_param = self .context .raw_param .get ("disable_azure_container_storage" )
8803+ container_storage_version = self .context .raw_param .get ("container_storage_version" )
8804+
8805+ if disable_azure_container_storage_param is not None and container_storage_version is not None :
8806+ raise InvalidArgumentValueError (
8807+ 'The --container-storage-version parameter is not required when disabling Azure Container Storage.'
8808+ ' Please remove this parameter and try again.'
8809+ )
8810+
88038811 if enable_azure_container_storage_param is not None or disable_azure_container_storage_param is not None :
8804- container_storage_version = self .context .raw_param .get ("container_storage_version" )
88058812 self .context .set_intermediate ("container_storage_version" , container_storage_version , overwrite_exists = True )
88068813
88078814 enable_azure_container_storage_v1 = enable_azure_container_storage_param is not None and container_storage_version == CONST_ACSTOR_VERSION_V1
0 commit comments