Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

18.0.0b28
+++++++
* Suppress enable ssh message when adding a new nodepool to the existed automatic cluster.

18.0.0b27
+++++++
* Add framework for interactive AI-powered debugging tool.
Expand Down
40 changes: 25 additions & 15 deletions src/aks-preview/azext_aks_preview/agentpool_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import os
from azure.cli.core.util import get_file_json
from types import SimpleNamespace
from typing import Dict, TypeVar, Union, List
from typing import Dict, TypeVar, Union, List, Optional

from azure.cli.command_modules.acs._consts import AgentPoolDecoratorMode, DecoratorMode, DecoratorEarlyExitException
from azure.cli.command_modules.acs.agentpool_decorator import (
Expand Down Expand Up @@ -41,6 +41,7 @@
CONST_DEFAULT_WINDOWS_NODE_VM_SIZE,
CONST_DEFAULT_VMS_VM_SIZE,
CONST_DEFAULT_WINDOWS_VMS_VM_SIZE,
CONST_MANAGED_CLUSTER_SKU_NAME_BASE,
CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC,
CONST_SSH_ACCESS_LOCALUSER,
CONST_GPU_DRIVER_NONE,
Expand All @@ -58,6 +59,7 @@
AgentPoolsOperations = TypeVar("AgentPoolsOperations")
PortRange = TypeVar("PortRange")
IPTag = TypeVar("IPTag")
ManagedCluster = TypeVar("ManagedCluster")


# pylint: disable=too-few-public-methods
Expand Down Expand Up @@ -568,8 +570,18 @@ def get_ssh_access(self) -> Union[str, None]:
"""
return self.raw_param.get("ssh_access")

def get_sku_name(self) -> str:
return self.raw_param.get("sku")
def get_sku_name(self, mc: ManagedCluster) -> str:
skuName = self.raw_param.get("sku")
if skuName is None:
if (
mc and
mc.sku and
getattr(mc.sku, 'name', None) is not None
):
skuName = vars(mc.sku)['name'].lower()
else:
skuName = CONST_MANAGED_CLUSTER_SKU_NAME_BASE
return skuName

def get_yes(self) -> bool:
"""Obtain the value of yes.
Expand Down Expand Up @@ -982,23 +994,21 @@ def set_up_artifact_streaming(self, agentpool: AgentPool) -> AgentPool:
agentpool.artifact_streaming_profile.enabled = True
return agentpool

def set_up_ssh_access(self, agentpool: AgentPool) -> AgentPool:
def set_up_ssh_access(self, agentpool: AgentPool, mc: Optional[ManagedCluster] = None) -> AgentPool:
self._ensure_agentpool(agentpool)

ssh_access = self.context.get_ssh_access()
sku_name = self.context.get_sku_name()
if ssh_access is not None:
sku_name = self.context.get_sku_name(mc)

if ssh_access is not None and not sku_name.lower() == CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC:
if agentpool.security_profile is None:
agentpool.security_profile = self.models.AgentPoolSecurityProfile() # pylint: disable=no-member
agentpool.security_profile.ssh_access = ssh_access
if ssh_access == CONST_SSH_ACCESS_LOCALUSER:
if sku_name == CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC:
logger.warning("SSH access is in preview")
else:
logger.warning(
"The new node pool will enable SSH access, recommended to use "
"'--ssh-access disabled' option to disable SSH access for the node pool to make it more secure."
)
logger.warning(
"The new node pool will enable SSH access, recommended to use "
"'--ssh-access disabled' option to disable SSH access for the node pool to make it more secure."
)
return agentpool

def set_up_skip_gpu_driver_install(self, agentpool: AgentPool) -> AgentPool:
Expand Down Expand Up @@ -1178,7 +1188,7 @@ def build_override(override_dict):
)
return agentpool

def construct_agentpool_profile_preview(self) -> AgentPool:
def construct_agentpool_profile_preview(self, mc: Optional[ManagedCluster] = None) -> AgentPool:
"""The overall controller used to construct the preview AgentPool profile.

The completely constructed AgentPool object will later be passed as a parameter to the underlying SDK
Expand Down Expand Up @@ -1219,7 +1229,7 @@ def construct_agentpool_profile_preview(self) -> AgentPool:
# set up driver_type
agentpool = self.set_up_driver_type(agentpool)
# set up agentpool ssh access
agentpool = self.set_up_ssh_access(agentpool)
agentpool = self.set_up_ssh_access(agentpool, mc)
# set up agentpool pod ip allocation mode
agentpool = self.set_up_pod_ip_allocation_mode(agentpool)
# set up secure boot
Expand Down
9 changes: 8 additions & 1 deletion src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,7 @@ def aks_agentpool_add(
# decorator pattern
from azure.cli.command_modules.acs._consts import AgentPoolDecoratorMode, DecoratorEarlyExitException
from azext_aks_preview.agentpool_decorator import AKSPreviewAgentPoolAddDecorator
from azext_aks_preview._client_factory import cf_managed_clusters
aks_agentpool_add_decorator = AKSPreviewAgentPoolAddDecorator(
cmd=cmd,
client=client,
Expand All @@ -1459,10 +1460,16 @@ def aks_agentpool_add(
)
try:
# construct agentpool profile
agentpool = aks_agentpool_add_decorator.construct_agentpool_profile_preview()
# get mc
mc_client = cf_managed_clusters(cmd.cli_ctx)
mc = mc_client.get(resource_group_name, cluster_name)
agentpool = aks_agentpool_add_decorator.construct_agentpool_profile_preview(mc)
except DecoratorEarlyExitException:
# exit gracefully
return None
except HttpResponseError as e:
logger.error("Failed to get managed cluster '%s' in resource group '%s': %s", cluster_name, resource_group_name, e)
return None
# send request to add a real agentpool
return aks_agentpool_add_decorator.add_agentpool(agentpool)

Expand Down
Loading
Loading