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} Add backward compatibility to cli #4047

Merged
merged 10 commits into from
Nov 1, 2021
Merged
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
6 changes: 5 additions & 1 deletion src/aks-preview/azext_aks_preview/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ def _populate_api_server_access_profile(api_server_authorized_ip_ranges, instanc
else:
profile = instance.api_server_access_profile

if api_server_authorized_ip_ranges == "":
if api_server_authorized_ip_ranges is None or api_server_authorized_ip_ranges == "":
authorized_ip_ranges = []
else:
authorized_ip_ranges = [ip.strip() for ip in api_server_authorized_ip_ranges.split(",")]

if profile.enable_private_cluster and authorized_ip_ranges:
raise ArgumentUsageError(
'--api-server-authorized-ip-ranges is not supported for private cluster')

profile.authorized_ip_ranges = authorized_ip_ranges
return profile

Expand Down
3 changes: 2 additions & 1 deletion src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from argcomplete.completers import FilesCompleter
from azure.cli.core.commands.parameters import (
file_type, get_resource_name_completion_list, get_three_state_flag, name_type, tags_type, zones_type, get_enum_type)
file_type, get_resource_name_completion_list, get_three_state_flag, name_type, tags_type, zones_type, edge_zone_type, get_enum_type)
from knack.arguments import CLIArgumentType

from ._completers import (
Expand Down Expand Up @@ -75,6 +75,7 @@ def load_arguments(self, _):
c.argument('aad_tenant_id')
c.argument('dns_service_ip')
c.argument('docker_bridge_address')
c.argument('edge_zone', edge_zone_type)
c.argument('load_balancer_sku', type=str, validator=validate_load_balancer_sku)
c.argument('load_balancer_managed_outbound_ip_count', type=int)
c.argument('load_balancer_outbound_ips', type=str, validator=validate_load_balancer_outbound_ips)
Expand Down
1 change: 0 additions & 1 deletion src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def load_command_table(self, _):
with self.command_group('aks', managed_clusters_sdk, client_factory=cf_managed_clusters) as g:
g.custom_command('kollect', 'aks_kollect')
g.custom_command('kanalyze', 'aks_kanalyze')
g.custom_command('browse', 'aks_browse')
Copy link
Contributor

@zhoxing-ms zhoxing-ms Nov 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FumingZhang If deleting this command will cause breaking change to the user, please mark it as [BREAKING CHANGE] in the history notes

Copy link
Member Author

@FumingZhang FumingZhang Nov 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zhoxing-ms, I suppose user should always have azure-cli installed before using aks-preview and if a command is not implemented in azure-cli-extensions, it will fall back to the implementation in azure-cli.

For this case, the implementation of aks browse is basically the same in azure-cli and azure-cli-extensions (actually a little bit more logic in azure-cli), and after removing this command declaration from the extension side, when aks browse is executed, the implementation in azure-cli will be used.

g.custom_command('create', 'aks_create', supports_no_wait=True)
g.custom_command('update', 'aks_update', supports_no_wait=True)
g.custom_command('scale', 'aks_scale', supports_no_wait=True)
Expand Down
6 changes: 4 additions & 2 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
ManagedClusterPodIdentity,
ManagedClusterPodIdentityException,
UserAssignedIdentity,
PowerState,
WindowsGmsaProfile)
PowerState)
from ._client_factory import cf_resource_groups
from ._client_factory import get_auth_management_client
from ._client_factory import get_graph_rbac_management_client
Expand Down Expand Up @@ -817,6 +816,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
enable_pod_identity_with_kubenet=False,
enable_encryption_at_host=False,
enable_ultra_ssd=False,
edge_zone=None,
enable_secret_rotation=False,
rotation_poll_interval=None,
disable_local_accounts=False,
Expand Down Expand Up @@ -937,6 +937,7 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to
license_type=windows_license_type)

if enable_windows_gmsa:
from .vendored_sdks.azure_mgmt_preview_aks.v2021_09_01.models import WindowsGmsaProfile
windows_profile.gmsa_profile = WindowsGmsaProfile(
enabled=True)
if gmsa_dns_server is not None and gmsa_root_domain_name is not None:
Expand Down Expand Up @@ -1742,6 +1743,7 @@ def aks_update(cmd, # pylint: disable=too-many-statements,too-many-branches,
instance.windows_profile.admin_password = windows_admin_password

if enable_windows_gmsa:
from .vendored_sdks.azure_mgmt_preview_aks.v2021_09_01.models import WindowsGmsaProfile
instance.windows_profile.gmsa_profile = WindowsGmsaProfile(enabled=True)
if gmsa_dns_server is not None and gmsa_root_domain_name is not None:
instance.windows_profile.gmsa_profile.dns_server = gmsa_dns_server
Expand Down
5 changes: 5 additions & 0 deletions src/aks-preview/azext_aks_preview/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def get_workload_runtime(self) -> Union[str, None]:
)
if (
agent_pool_profile and
hasattr(agent_pool_profile, "workload_runtime") and # backward compatibility
agent_pool_profile.workload_runtime is not None
):
workload_runtime = agent_pool_profile.workload_runtime
Expand All @@ -238,6 +239,7 @@ def get_gpu_instance_profile(self) -> Union[str, None]:
)
if (
agent_pool_profile and
hasattr(agent_pool_profile, "gpu_instance_profile") and # backward compatibility
agent_pool_profile.gpu_instance_profile is not None
):
gpu_instance_profile = agent_pool_profile.gpu_instance_profile
Expand Down Expand Up @@ -756,6 +758,7 @@ def _get_enable_windows_gmsa(self, enable_validation: bool = False, **kwargs) ->
if (
self.mc and
self.mc.windows_profile and
hasattr(self.mc.windows_profile, "gmsa_profile") and # backward compatibility
self.mc.windows_profile.gmsa_profile and
self.mc.windows_profile.gmsa_profile.enabled is not None
):
Expand Down Expand Up @@ -806,6 +809,7 @@ def _get_gmsa_dns_server_and_root_domain_name(self, enable_validation: bool = Fa
if (
self.mc and
self.mc.windows_profile and
hasattr(self.mc.windows_profile, "gmsa_profile") and # backward compatibility
self.mc.windows_profile.gmsa_profile and
self.mc.windows_profile.gmsa_profile.dns_server is not None
):
Expand All @@ -820,6 +824,7 @@ def _get_gmsa_dns_server_and_root_domain_name(self, enable_validation: bool = Fa
if (
self.mc and
self.mc.windows_profile and
hasattr(self.mc.windows_profile, "gmsa_profile") and # backward compatibility
self.mc.windows_profile.gmsa_profile and
self.mc.windows_profile.gmsa_profile.root_domain_name is not None
):
Expand Down