|
52 | 52 | CONST_ACSTOR_EXT_INSTALLATION_NAME, |
53 | 53 | CONST_ACSTOR_V1_EXT_INSTALLATION_NAME, |
54 | 54 | CONST_ACSTOR_VERSION_V1, |
| 55 | + CONST_SUPPORTED_ACSTOR_VERSIONS, |
55 | 56 | ) |
56 | 57 | from azure.cli.command_modules.acs._helpers import ( |
57 | 58 | check_is_managed_aad_cluster, |
@@ -6781,102 +6782,108 @@ def set_up_azure_container_storage(self, mc: ManagedCluster) -> ManagedCluster: |
6781 | 6782 | if self.context.raw_param.get("enable_azure_container_storage") is not None: |
6782 | 6783 | self.context.set_intermediate("enable_azure_container_storage", True, overwrite_exists=True) |
6783 | 6784 | 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 | | - ) |
6803 | 6785 |
|
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 |
| 6786 | + if container_storage_version is not None and container_storage_version not in CONST_SUPPORTED_ACSTOR_VERSIONS: |
| 6787 | + raise InvalidArgumentValueError( |
| 6788 | + f'Version {container_storage_version} is not supported for enabling Azure Container Storage. ' |
| 6789 | + f'The only supported versions are {CONST_SUPPORTED_ACSTOR_VERSIONS}' |
| 6790 | + ) |
6824 | 6791 |
|
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 | | - ) |
| 6792 | + if container_storage_version is not None and container_storage_version == CONST_ACSTOR_VERSION_V1: |
| 6793 | + # read the azure container storage values passed |
| 6794 | + pool_type = self.context.raw_param.get("enable_azure_container_storage") |
| 6795 | + enable_azure_container_storage = pool_type is not None |
| 6796 | + ephemeral_disk_volume_type = self.context.raw_param.get("ephemeral_disk_volume_type") |
| 6797 | + ephemeral_disk_nvme_perf_tier = self.context.raw_param.get("ephemeral_disk_nvme_perf_tier") |
| 6798 | + if (ephemeral_disk_volume_type is not None or ephemeral_disk_nvme_perf_tier is not None) and \ |
| 6799 | + not enable_azure_container_storage: |
| 6800 | + params_defined_arr = [] |
| 6801 | + if ephemeral_disk_volume_type is not None: |
| 6802 | + params_defined_arr.append('--ephemeral-disk-volume-type') |
| 6803 | + if ephemeral_disk_nvme_perf_tier is not None: |
| 6804 | + params_defined_arr.append('--ephemeral-disk-nvme-perf-tier') |
6859 | 6805 |
|
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 | | - ) |
| 6806 | + params_defined = 'and '.join(params_defined_arr) |
| 6807 | + raise RequiredArgumentMissingError( |
| 6808 | + f'Cannot set {params_defined} without the parameter --enable-azure-container-storage.' |
| 6809 | + ) |
| 6810 | + |
| 6811 | + if enable_azure_container_storage: |
| 6812 | + pool_name = self.context.raw_param.get("storage_pool_name") |
| 6813 | + pool_option = self.context.raw_param.get("storage_pool_option") |
| 6814 | + pool_sku = self.context.raw_param.get("storage_pool_sku") |
| 6815 | + pool_size = self.context.raw_param.get("storage_pool_size") |
| 6816 | + if not mc.agent_pool_profiles: |
| 6817 | + raise UnknownError("Encountered an unexpected error while getting the agent pools from the cluster.") |
| 6818 | + agentpool = mc.agent_pool_profiles[0] |
| 6819 | + agentpool_details = {} |
| 6820 | + pool_details = {} |
| 6821 | + pool_details["vm_size"] = agentpool.vm_size |
| 6822 | + pool_details["count"] = agentpool.count |
| 6823 | + pool_details["os_type"] = agentpool.os_type |
| 6824 | + pool_details["mode"] = agentpool.mode |
| 6825 | + pool_details["node_taints"] = agentpool.node_taints |
| 6826 | + pool_details["zoned"] = agentpool.availability_zones is not None |
| 6827 | + agentpool_details[agentpool.name] = pool_details |
| 6828 | + # Marking the only agentpool name as the valid nodepool for |
| 6829 | + # installing Azure Container Storage during `az aks create` |
| 6830 | + nodepool_list = agentpool.name |
| 6831 | + |
| 6832 | + from azure.cli.command_modules.acs.azurecontainerstorage._validators import ( |
| 6833 | + validate_enable_azure_container_storage_v1_params |
| 6834 | + ) |
| 6835 | + from azure.cli.command_modules.acs.azurecontainerstorage._consts import ( |
| 6836 | + CONST_ACSTOR_IO_ENGINE_LABEL_KEY, |
| 6837 | + CONST_ACSTOR_IO_ENGINE_LABEL_VAL, |
| 6838 | + CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY, |
| 6839 | + CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD, |
| 6840 | + ) |
| 6841 | + from azure.cli.command_modules.acs.azurecontainerstorage._helpers import generate_vm_sku_cache_for_region |
| 6842 | + generate_vm_sku_cache_for_region(self.cmd.cli_ctx, self.context.get_location()) |
| 6843 | + |
| 6844 | + default_ephemeral_disk_volume_type = CONST_DISK_TYPE_EPHEMERAL_VOLUME_ONLY |
| 6845 | + default_ephemeral_disk_nvme_perf_tier = CONST_EPHEMERAL_NVME_PERF_TIER_STANDARD |
| 6846 | + validate_enable_azure_container_storage_v1_params( |
| 6847 | + pool_type, |
| 6848 | + pool_name, |
| 6849 | + pool_sku, |
| 6850 | + pool_option, |
| 6851 | + pool_size, |
| 6852 | + nodepool_list, |
| 6853 | + agentpool_details, |
| 6854 | + False, |
| 6855 | + False, |
| 6856 | + "", |
| 6857 | + False, |
| 6858 | + False, |
| 6859 | + False, |
| 6860 | + False, |
| 6861 | + ephemeral_disk_volume_type, |
| 6862 | + ephemeral_disk_nvme_perf_tier, |
| 6863 | + default_ephemeral_disk_volume_type, |
| 6864 | + default_ephemeral_disk_nvme_perf_tier, |
| 6865 | + ) |
| 6866 | + |
| 6867 | + # Setup Azure Container Storage labels on the nodepool |
| 6868 | + nodepool_labels = agentpool.node_labels |
| 6869 | + if nodepool_labels is None: |
| 6870 | + nodepool_labels = {} |
| 6871 | + nodepool_labels[CONST_ACSTOR_IO_ENGINE_LABEL_KEY] = CONST_ACSTOR_IO_ENGINE_LABEL_VAL |
| 6872 | + agentpool.node_labels = nodepool_labels |
| 6873 | + |
| 6874 | + # set intermediates |
| 6875 | + self.context.set_intermediate("container_storage_version", container_storage_version, overwrite_exists=True) |
| 6876 | + self.context.set_intermediate("azure_container_storage_nodepools", nodepool_list, overwrite_exists=True) |
| 6877 | + self.context.set_intermediate( |
| 6878 | + "current_ephemeral_nvme_perf_tier", |
| 6879 | + default_ephemeral_disk_nvme_perf_tier, |
| 6880 | + overwrite_exists=True |
| 6881 | + ) |
| 6882 | + self.context.set_intermediate( |
| 6883 | + "existing_ephemeral_disk_volume_type", |
| 6884 | + default_ephemeral_disk_volume_type, |
| 6885 | + overwrite_exists=True |
| 6886 | + ) |
6880 | 6887 | else: |
6881 | 6888 | enable_azure_container_storage = self.context.raw_param.get("enable_azure_container_storage") |
6882 | 6889 | storage_pool_name = self.context.raw_param.get("storage_pool_name") |
@@ -8800,8 +8807,21 @@ def update_azure_container_storage(self, mc: ManagedCluster) -> ManagedCluster: |
8800 | 8807 | # check if we are trying to enable container storage v1 |
8801 | 8808 | enable_azure_container_storage_param = self.context.raw_param.get("enable_azure_container_storage") |
8802 | 8809 | disable_azure_container_storage_param = self.context.raw_param.get("disable_azure_container_storage") |
| 8810 | + container_storage_version = self.context.raw_param.get("container_storage_version") |
| 8811 | + |
| 8812 | + if disable_azure_container_storage_param is not None and container_storage_version is not None: |
| 8813 | + raise InvalidArgumentValueError( |
| 8814 | + 'The --container-storage-version parameter is not required when disabling Azure Container Storage.' |
| 8815 | + ' Please remove this parameter and try again.' |
| 8816 | + ) |
| 8817 | + |
| 8818 | + if container_storage_version is not None and container_storage_version not in CONST_SUPPORTED_ACSTOR_VERSIONS: |
| 8819 | + raise InvalidArgumentValueError( |
| 8820 | + f'Version {container_storage_version} is not supported for enabling Azure Container Storage. ' |
| 8821 | + f'The only supported versions are {CONST_SUPPORTED_ACSTOR_VERSIONS}' |
| 8822 | + ) |
| 8823 | + |
8803 | 8824 | 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") |
8805 | 8825 | self.context.set_intermediate("container_storage_version", container_storage_version, overwrite_exists=True) |
8806 | 8826 |
|
8807 | 8827 | enable_azure_container_storage_v1 = enable_azure_container_storage_param is not None and container_storage_version == CONST_ACSTOR_VERSION_V1 |
|
0 commit comments