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

add --ampls-resource-id and --enable-high-log-scale-mode options #7754

Merged
merged 28 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ae7e6bb
add --ampls-resource-id and --enable-high-log-scale-mode options
ganga1980 Jun 28, 2024
1aed0eb
fix pr feedback
ganga1980 Jun 28, 2024
064d7e0
fix pr feedback
ganga1980 Jun 28, 2024
85bbb7c
resolve merge conflicts
ganga1980 Jun 28, 2024
c560c45
Merge branch 'Azure:main' into main
ganga1980 Jun 28, 2024
103ee15
resolve merge conflicts
ganga1980 Jun 28, 2024
6121ff8
Merge branch 'main' of github.com:ganga1980/azure-cli-extensions into…
ganga1980 Jun 28, 2024
3f7c7dd
add live tests
ganga1980 Jun 28, 2024
13ee00f
fix pr feedback
ganga1980 Jun 28, 2024
65c4e64
fix pr feedback
ganga1980 Jun 28, 2024
2124e2a
fix pr feedback
ganga1980 Jun 28, 2024
5f3d03b
lint errors
ganga1980 Jun 28, 2024
3dcda47
fix merge conflicts
ganga1980 Jul 16, 2024
3c7de7e
comment tests since require latest az cli
ganga1980 Jul 17, 2024
2534b11
fix merge conflicts
ganga1980 Jul 17, 2024
a760193
Merge branch 'Azure:main' into main
ganga1980 Jul 22, 2024
728aa2e
re-enable tests
ganga1980 Jul 22, 2024
8077f6a
fix pr feedback
ganga1980 Jul 22, 2024
ca413b9
fix merge conflicts
ganga1980 Jul 26, 2024
c5b5ef6
fix lint errors
ganga1980 Jul 26, 2024
957b9ef
Merge branch 'Azure:main' into main
ganga1980 Jul 29, 2024
56ba2ce
Merge branch 'Azure:main' into main
ganga1980 Jul 30, 2024
0f37111
Merge branch 'Azure:main' into main
ganga1980 Jul 31, 2024
8f9fb5c
fix bug
ganga1980 Jul 31, 2024
bebdae5
fix lint errors
ganga1980 Jul 31, 2024
ad84ede
fix lint errors
ganga1980 Jul 31, 2024
007f7af
fix lint errors
ganga1980 Jul 31, 2024
9a6d01c
bump aks-preview version
ganga1980 Jul 31, 2024
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
7 changes: 6 additions & 1 deletion src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

7.0.0b3
++++++++
* Add option `--enable-high-log-scale-mode` to `az aks create --enable-addons monitoring` and `az aks enable-addons -a monitoring` .
* Add option `--ampls-resource-id` to `az aks create --enable-addons monitoring` and `az aks enable-addons -a monitoring` .

7.0.0b2
++++++++
* Update the minimum required cli core version to `2.61.0`.
* Add option `--enable-imds-restriction --disable-imds-restriction` to `az aks create` and `az aks update`.
* Add option `--enable-imds-restriction --disable-imds-restriction` to `az aks create` and `az aks update`.
* Introduce valdations to `az aks create` and `az aks update` while using PremiumV2 disk during enabling Azure Container Storage.
* Delete the Azure Container Storage installation after failure to prevent retries.

Expand Down
24 changes: 24 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@
- name: --data-collection-settings
type: string
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
- name: --enable-cluster-autoscaler
type: bool
short-summary: Enable cluster autoscaler, default value is false.
Expand Down Expand Up @@ -2307,6 +2313,12 @@
- name: --data-collection-settings
type: string
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
- name: --subnet-name -s
type: string
short-summary: The subnet name for the virtual node to use.
Expand Down Expand Up @@ -2374,6 +2386,12 @@
- name: --data-collection-settings
type: string
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
- name: --subnet-name -s
type: string
short-summary: The subnet name for the virtual node to use.
Expand Down Expand Up @@ -2455,6 +2473,12 @@
- name: --data-collection-settings
type: string
short-summary: Path to JSON file containing data collection settings for Monitoring addon.
- name: --enable-high-log-scale-mode
type: bool
short-summary: Enable High Log Scale Mode for Container Logs.
- name: --ampls-resource-id
type: string
short-summary: Resource ID of Azure Monitor Private Link scope for Monitoring Addon.
- name: --subnet-name -s
type: string
short-summary: The subnet name for the virtual node to use.
Expand Down
16 changes: 16 additions & 0 deletions src/aks-preview/azext_aks_preview/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import platform
import re
import stat
import sys
import tempfile
from typing import TypeVar

Expand Down Expand Up @@ -330,3 +331,18 @@ def process_message_for_run_command(message):

for line in result[2:len(result) - 2]:
print(line)


def check_is_azure_cli_core_editable_installed():
try:
editable = os.getenv("AZURE_CLI_CORE_EDITABLE", "false").lower() == "true"
if editable:
return True
for path_item in sys.path:
egg_link = os.path.join(path_item, 'azure-cli-core.egg-link')
if os.path.isfile(egg_link):
os.environ["AZURE_CLI_CORE_EDITABLE"] = "true"
return True
except Exception as ex: # pylint: disable=broad-except
logger.debug("failed to check if azure-cli-core is installed as editable: %s", ex)
return False
8 changes: 8 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ def load_arguments(self, _):
)
c.argument("enable_syslog", arg_type=get_three_state_flag(), is_preview=True)
c.argument("data_collection_settings", is_preview=True)
c.argument("enable_high_log_scale_mode", arg_type=get_three_state_flag(), is_preview=True)
c.argument("ampls_resource_id", is_preview=True)
c.argument("aci_subnet_name")
c.argument("appgw_name", arg_group="Application Gateway")
c.argument("appgw_subnet_cidr", arg_group="Application Gateway")
Expand Down Expand Up @@ -1856,6 +1858,8 @@ def load_arguments(self, _):
)
c.argument("enable_syslog", arg_type=get_three_state_flag(), is_preview=True)
c.argument("data_collection_settings", is_preview=True)
c.argument("enable_high_log_scale_mode", arg_type=get_three_state_flag(), is_preview=True)
c.argument("ampls_resource_id", is_preview=True)
c.argument(
"dns_zone_resource_id",
deprecate_info=c.deprecate(
Expand Down Expand Up @@ -1911,6 +1915,8 @@ def load_arguments(self, _):
)
c.argument("enable_syslog", arg_type=get_three_state_flag(), is_preview=True)
c.argument("data_collection_settings", is_preview=True)
c.argument("enable_high_log_scale_mode", arg_type=get_three_state_flag(), is_preview=True)
c.argument("ampls_resource_id", is_preview=True)
c.argument(
"dns_zone_resource_id",
deprecate_info=c.deprecate(
Expand Down Expand Up @@ -1949,6 +1955,8 @@ def load_arguments(self, _):
)
c.argument("enable_syslog", arg_type=get_three_state_flag(), is_preview=True)
c.argument("data_collection_settings", is_preview=True)
c.argument("enable_high_log_scale_mode", arg_type=get_three_state_flag(), is_preview=True)
c.argument("ampls_resource_id", is_preview=True)
c.argument(
"dns_zone_resource_id",
deprecate_info=c.deprecate(
Expand Down
15 changes: 8 additions & 7 deletions src/aks-preview/azext_aks_preview/addonconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ def enable_addons(
dns_zone_resource_ids=None,
enable_msi_auth_for_monitoring=True,
enable_syslog=False,
data_collection_settings=None
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False,
):
instance = client.get(resource_group_name, name)
# this is overwritten by _update_addons(), so the value needs to be recorded here
Expand Down Expand Up @@ -99,9 +101,7 @@ def enable_addons(
rotation_poll_interval=rotation_poll_interval,
no_wait=no_wait,
dns_zone_resource_id=dns_zone_resource_id,
dns_zone_resource_ids=dns_zone_resource_ids,
enable_syslog=enable_syslog,
data_collection_settings=data_collection_settings,
dns_zone_resource_ids=dns_zone_resource_ids
)

if CONST_MONITORING_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
Expand All @@ -124,7 +124,9 @@ def enable_addons(
create_dcr=True,
create_dcra=True,
enable_syslog=enable_syslog,
data_collection_settings=data_collection_settings
data_collection_settings=data_collection_settings,
ampls_resource_id=ampls_resource_id,
enable_high_log_scale_mode=enable_high_log_scale_mode
)
else:
# monitoring addon will use legacy path
Expand Down Expand Up @@ -204,8 +206,6 @@ def update_addons(
dns_zone_resource_id=None,
dns_zone_resource_ids=None,
no_wait=False, # pylint: disable=unused-argument
enable_syslog=False, # pylint: disable=unused-argument
data_collection_settings=None, # pylint: disable=unused-argument
):
# parse the comma-separated addons argument
addon_args = addons.split(',')
Expand Down Expand Up @@ -398,6 +398,7 @@ def add_ingress_appgw_addon_role_assignment(result, cmd):
service_principal_msi_id = None
# Check if service principal exists, if it does, assign permissions to service principal
# Else, provide permissions to MSI
is_service_principal = False
if (
hasattr(result, 'service_principal_profile') and
hasattr(result.service_principal_profile, 'client_id') and
Expand Down
30 changes: 24 additions & 6 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ def aks_create(
enable_msi_auth_for_monitoring=True,
enable_syslog=False,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False,
aci_subnet_name=None,
appgw_name=None,
appgw_subnet_cidr=None,
Expand Down Expand Up @@ -2014,6 +2016,8 @@ def aks_addon_enable(
dns_zone_resource_ids=None,
enable_syslog=False,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False
):
return enable_addons(
cmd,
Expand All @@ -2038,6 +2042,8 @@ def aks_addon_enable(
dns_zone_resource_ids=dns_zone_resource_ids,
enable_syslog=enable_syslog,
data_collection_settings=data_collection_settings,
ampls_resource_id=ampls_resource_id,
enable_high_log_scale_mode=enable_high_log_scale_mode
)


Expand Down Expand Up @@ -2068,6 +2074,8 @@ def aks_addon_update(
dns_zone_resource_ids=None,
enable_syslog=False,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False
):
instance = client.get(resource_group_name, name)
addon_profiles = instance.addon_profiles
Expand Down Expand Up @@ -2117,6 +2125,8 @@ def aks_addon_update(
dns_zone_resource_ids=dns_zone_resource_ids,
enable_syslog=enable_syslog,
data_collection_settings=data_collection_settings,
ampls_resource_id=ampls_resource_id,
enable_high_log_scale_mode=enable_high_log_scale_mode
)


Expand Down Expand Up @@ -2151,6 +2161,8 @@ def aks_disable_addons(cmd, client, resource_group_name, name, addons, no_wait=F
create_dcra=True,
enable_syslog=False,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False
)
except TypeError:
pass
Expand Down Expand Up @@ -2193,6 +2205,8 @@ def aks_enable_addons(
dns_zone_resource_ids=None,
enable_syslog=False,
data_collection_settings=None,
ampls_resource_id=None,
enable_high_log_scale_mode=False,
aks_custom_headers=None,
):
headers = get_aks_custom_headers(aks_custom_headers)
Expand Down Expand Up @@ -2228,8 +2242,6 @@ def aks_enable_addons(
no_wait=no_wait,
dns_zone_resource_id=dns_zone_resource_id,
dns_zone_resource_ids=dns_zone_resource_ids,
enable_syslog=enable_syslog,
data_collection_settings=data_collection_settings,
)
if (
CONST_MONITORING_ADDON_NAME in instance.addon_profiles and
Expand Down Expand Up @@ -2260,14 +2272,21 @@ def aks_enable_addons(
create_dcra=True,
enable_syslog=enable_syslog,
data_collection_settings=data_collection_settings,
ampls_resource_id=ampls_resource_id,
enable_high_log_scale_mode=enable_high_log_scale_mode
)
else:
# monitoring addon will use legacy path
if enable_syslog:
raise ArgumentUsageError(
"--enable-syslog can not be used without MSI auth.")
if enable_high_log_scale_mode:
raise ArgumentUsageError(
"--enable-high-log-scale-mode can not be used without MSI auth.")
if data_collection_settings is not None:
raise ArgumentUsageError("--data-collection-settings can not be used without MSI auth.")
if ampls_resource_id is not None:
raise ArgumentUsageError("--ampls-resource-id can not be used without MSI auth.")
ensure_container_insights_for_monitoring(
cmd,
instance.addon_profiles[CONST_MONITORING_ADDON_NAME],
Expand Down Expand Up @@ -2316,7 +2335,7 @@ def aks_rotate_certs(cmd, client, resource_group_name, name, no_wait=True):
return sdk_no_wait(no_wait, client.begin_rotate_cluster_certificates, resource_group_name, name)


def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements,
instance,
subscription_id,
resource_group_name,
Expand All @@ -2338,9 +2357,8 @@ def _update_addons(cmd, # pylint: disable=too-many-branches,too-many-statements
rotation_poll_interval=None,
dns_zone_resource_id=None,
dns_zone_resource_ids=None,
no_wait=False, # pylint: disable=unused-argument
enable_syslog=False,
data_collection_settings=None):
no_wait=False,): # pylint: disable=unused-argument

ManagedClusterAddonProfile = cmd.get_models(
"ManagedClusterAddonProfile",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
Expand Down
38 changes: 38 additions & 0 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
)
from azext_aks_preview._helpers import (
check_is_apiserver_vnet_integration_cluster,
check_is_azure_cli_core_editable_installed,
check_is_private_cluster,
get_cluster_snapshot_by_snapshot_id,
setup_common_safeguards_profile,
Expand Down Expand Up @@ -3733,10 +3734,43 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
# set up imds restriction(a property in network profile)
mc = self.set_up_imds_restriction(mc)

# validate the azure cli core version
self.verify_cli_core_version()

# DO NOT MOVE: keep this at the bottom, restore defaults
mc = self._restore_defaults_in_mc(mc)
return mc

def verify_cli_core_version(self):
from azure.cli.core import __version__ as core_version
monitor_options_specified = False
# in case in a super old version, the options are not available
try:
monitor_options_specified = any(
(
self.context.get_ampls_resource_id(),
self.context.get_enable_high_log_scale_mode(),
)
)
except Exception as ex: # pylint: disable=broad-except
logger.debug("failed to get the value of monitor_options: %s", ex)
monitor_options_specified = any(
(
self.__raw_parameters.get("ampls_resource_id"),
self.__raw_parameters.get("enable_high_log_scale_mode"),
)
)
finally:
if monitor_options_specified and (
core_version < "2.63.0" and
Copy link
Member

Choose a reason for hiding this comment

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

not blocking: it would be better to do the comparison semantically

not check_is_azure_cli_core_editable_installed()
):
raise ArgumentUsageError(
f"The --ampls-resource-id and --enable-high-log-scale-mode options are only available in Azure CLI "
f"version 2.63.0 and later. Your current Azure CLI version is {core_version}. Please upgrade your "
"Azure CLI."
)

def check_is_postprocessing_required(self, mc: ManagedCluster) -> bool:
"""Helper function to check if postprocessing is required after sending a PUT request to create the cluster.

Expand Down Expand Up @@ -3842,6 +3876,10 @@ def postprocessing_after_mc_created(self, cluster: ManagedCluster) -> None:
create_dcr=False,
create_dcra=True,
enable_syslog=self.context.get_enable_syslog(),
data_collection_settings=self.context.get_data_collection_settings(),
is_private_cluster=self.context.get_enable_private_cluster(),
ampls_resource_id=self.context.get_ampls_resource_id(),
enable_high_log_scale_mode=self.context.get_enable_high_log_scale_mode(),
)

# ingress appgw addon
Expand Down
Loading
Loading