Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AKS: Fix scenarios around nodepool and storagepool name for Azure Container Storage #6911

Merged
merged 12 commits into from
Oct 30, 2023
Merged
5 changes: 5 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Pending
+++++++
* Vendor new SDK and bump API version to 2023-09-02-preview.

0.5.167
+++++++
* Fix the default storagepool name value created for Azure Container Storage.
* Ensure the correct nodepool name is picked by Azure Container Storage while installing with `az aks create`.

0.5.166
+++++++
* Add `--network-policy` to the `az aks update` command.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,4 @@
CONST_STORAGE_POOL_TYPE_ELASTIC_SAN = "elasticSan"
CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK = "ephemeralDisk"

CONST_STORAGE_POOL_RANDOM_LENGTH = 7
RP_REGISTRATION_POLLING_INTERVAL_IN_SEC = 5
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
CONST_K8S_EXTENSION_NAME,
CONST_STORAGE_POOL_NAME_PREFIX,
CONST_STORAGE_POOL_OPTION_NVME,
CONST_STORAGE_POOL_RANDOM_LENGTH,
CONST_STORAGE_POOL_TYPE_ELASTIC_SAN,
CONST_STORAGE_POOL_TYPE_EPHEMERAL_DISK,
RP_REGISTRATION_POLLING_INTERVAL_IN_SEC,
)

from datetime import datetime
from knack.log import get_logger
import random
import string
import time

logger = get_logger(__name__)
Expand Down Expand Up @@ -150,11 +147,6 @@ def perform_role_operations_on_managed_rg(cmd, subscription_id, node_resource_gr
return False


def generate_random_storage_pool_name():
random_name = CONST_STORAGE_POOL_NAME_PREFIX + ''.join(random.choices(string.ascii_lowercase, k=CONST_STORAGE_POOL_RANDOM_LENGTH))
return random_name


def get_k8s_extension_module(module_name):
try:
# adding the installed extension in the path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
)
from azext_aks_preview.azurecontainerstorage._helpers import (
check_if_extension_is_installed,
generate_random_storage_pool_name,
get_k8s_extension_module,
perform_role_operations_on_managed_rg,
register_dependent_rps,
Expand Down Expand Up @@ -101,7 +100,7 @@ def perform_enable_azure_container_storage(
config_settings = []
if create_storage_pool:
if storage_pool_name is None:
storage_pool_name = generate_random_storage_pool_name()
storage_pool_name = storage_pool_type.lower()
if storage_pool_size is None:
storage_pool_size = CONST_STORAGE_POOL_DEFAULT_SIZE_ESAN if \
storage_pool_type == CONST_STORAGE_POOL_TYPE_ELASTIC_SAN else \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3115,8 +3115,10 @@ def postprocessing_after_mc_created(self, cluster: ManagedCluster) -> None:
kubelet_identity_object_id = cluster.identity_profile["kubeletidentity"].object_id
node_resource_group = cluster.node_resource_group
agent_pool_details = {}
nodepool_name = "nodepool1"
for agentpool_profile in cluster.agent_pool_profiles:
agent_pool_details[agentpool_profile.name] = agentpool_profile.vm_size
nodepool_name = agentpool_profile.name
mukhoakash marked this conversation as resolved.
Show resolved Hide resolved

self.context.external_functions.perform_enable_azure_container_storage(
self.cmd,
Expand All @@ -3130,7 +3132,7 @@ def postprocessing_after_mc_created(self, cluster: ManagedCluster) -> None:
pool_size,
pool_sku,
pool_option,
"nodepool1",
nodepool_name,
agent_pool_details,
True,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6759,6 +6759,47 @@ def test_aks_create_with_azurecontainerstorage(self, resource_group, resource_gr
self.is_empty(),
])

# live only due to downloading k8s-extension extension
@live_only()
mukhoakash marked this conversation as resolved.
Show resolved Hide resolved
@AllowLargeResponse(8192)
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
def test_aks_create_with_azurecontainerstorage_with_nodepool_name(self, resource_group, resource_group_location):
# reset the count so in replay mode the random names will start with 0
self.test_resources_count = 0
# kwargs for string formatting
aks_name = self.create_random_name('cliakstest', 16)
nodepool_name = self.create_random_name('n', 6)

node_vm_size = 'standard_d4s_v3'
self.kwargs.update({
'resource_group': resource_group,
'name': aks_name,
'location': resource_group_location,
'resource_type': 'Microsoft.ContainerService/ManagedClusters',
'ssh_key_value': self.generate_ssh_keys(),
'node_vm_size': node_vm_size,
'nodepool_name': nodepool_name
})

# add k8s-extension extension for azurecontainerstorage operations.
self.cmd('extension add --name k8s-extension')

create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} --ssh-key-value={ssh_key_value} --node-vm-size={node_vm_size} ' \
'--node-count 3 --nodepool-name {nodepool_name} --enable-managed-identity --enable-azure-container-storage azureDisk --output=json'

# enabling azurecontainerstorage will not affect any field in the cluster.
# the only check we should perform is to verify that the cluster is provisioned successfully.
self.cmd(create_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('agentPoolProfiles[0].name', nodepool_name),
])

# delete
cmd = 'aks delete --resource-group={resource_group} --name={name} --yes --no-wait'
self.cmd(cmd, checks=[
self.is_empty(),
])

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
def test_aks_update_with_azuremonitormetrics(self, resource_group, resource_group_location):
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import setup, find_packages

VERSION = "0.5.166"
VERSION = "0.5.167"

CLASSIFIERS = [
"Development Status :: 4 - Beta",
Expand Down