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] Filter out NoSchedule initialization taints when targettting a system pool in request #7737

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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 @@ -18,6 +18,10 @@ Pending
* Add option `--azure-container-storage-perf-tier` to `az aks create` and `az aks update` to define resource tiers for Azure Container Storage performance.
* Vendor new SDK and bump API version to 2024-04-02-preview.

5.0.1b1
++++++++
* Only send soft initialization taints in request body when initialization taints are being added to a system node pool

5.0.0b1
++++++++
* [BREAKING CHANGE]: Remove --enable-network-observability and --disable-network-observability from aks create and update commands.
Expand Down
10 changes: 9 additions & 1 deletion src/aks-preview/azext_aks_preview/agentpool_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from azext_aks_preview._client_factory import cf_agent_pools
from azext_aks_preview._consts import (
CONST_NODEPOOL_MODE_SYSTEM,
CONST_WORKLOAD_RUNTIME_OCI_CONTAINER,
CONST_VIRTUAL_MACHINE_SCALE_SETS,
CONST_AVAILABILITY_SET,
Expand Down Expand Up @@ -414,7 +415,14 @@ def get_node_initialization_taints(self) -> Union[List[str], None]:
if self.agentpool and self.agentpool.node_initialization_taints is not None:
node_init_taints = self.agentpool.node_initialization_taints

# this parameter does not need validation
# if this is for a system agent pool, we remove hard taints as they cannot be installed on system pools,
# but we still want them on user pools
if self.agentpool and self.agentpool.mode == CONST_NODEPOOL_MODE_SYSTEM and node_init_taints:
soft_taints_for_system_pool = []
for init_taint in node_init_taints:
if ":noschedule" not in init_taint.lower():
soft_taints_for_system_pool.append(init_taint)
node_init_taints = soft_taints_for_system_pool
return node_init_taints

def get_drain_timeout(self):
Expand Down
11 changes: 10 additions & 1 deletion src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
CONST_DNS_ZONE_CONTRIBUTOR_ROLE,
CONST_ARTIFACT_SOURCE_CACHE,
CONST_OUTBOUND_TYPE_NONE,
CONST_NODEPOOL_MODE_SYSTEM
)
from azext_aks_preview._helpers import (
check_is_apiserver_vnet_integration_cluster,
Expand Down Expand Up @@ -3926,6 +3927,10 @@ def postprocessing_after_mc_created(self, cluster: ManagedCluster) -> None:
)


def getSoftInitTaints(nodepool_initialization_taints):
return ["test"]


class AKSPreviewManagedClusterUpdateDecorator(AKSManagedClusterUpdateDecorator):
def __init__(
self, cmd: AzCliCommand, client: ContainerServiceClient, raw_parameters: Dict, resource_type: ResourceType
Expand Down Expand Up @@ -5018,7 +5023,11 @@ def update_nodepool_initialization_taints_mc(self, mc: ManagedCluster) -> Manage
nodepool_initialization_taints = self.context.get_nodepool_initialization_taints()
if nodepool_initialization_taints is not None:
for agent_profile in mc.agent_pool_profiles:
agent_profile.node_initialization_taints = nodepool_initialization_taints
if agent_profile.mode == CONST_NODEPOOL_MODE_SYSTEM:
soft_init_taints = getSoftInitTaints(nodepool_initialization_taints)
agent_profile.node_initialization_taints = soft_init_taints
else:
agent_profile.node_initialization_taints = nodepool_initialization_taints
return mc

def update_cost_analysis(self, mc: ManagedCluster) -> ManagedCluster:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14233,9 +14233,9 @@ def test_aks_create_cluster_with_taints(self, resource_group, resource_group_loc
"taint1=value1:PreferNoSchedule,taint2=value2:PreferNoSchedule"
)
nodepool_init_taints = (
"initTaint1=value1:PreferNoSchedule,initTaint2=value2:PreferNoSchedule"
"initTaint1=value1:NoSchedule,initTaint2=value3:PreferNoSchedule"
)
nodepool_taints2 = "taint1=value2:PreferNoSchedule"
nodepool_taints2 = "taint1=value2:NoSchedule,taint2=value3:PreferNoSchedule"
nodepool_init_taints2 = "initTaint1=value2:PreferNoSchedule"
self.kwargs.update(
{
Expand Down Expand Up @@ -14280,10 +14280,6 @@ def test_aks_create_cluster_with_taints(self, resource_group, resource_group_loc
),
self.check(
"agentPoolProfiles[0].nodeInitializationTaints[0]",
"initTaint1=value1:PreferNoSchedule",
),
self.check(
"agentPoolProfiles[0].nodeInitializationTaints[1]",
"initTaint2=value2:PreferNoSchedule",
),
],
Expand All @@ -14306,7 +14302,7 @@ def test_aks_create_cluster_with_taints(self, resource_group, resource_group_loc
),
self.check(
"agentPoolProfiles[0].nodeInitializationTaints[0]",
"initTaint1=value2:PreferNoSchedule",
"initTaint2=value3:PreferNoSchedule",
),
],
)
Expand Down
Loading