Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ganga1980 committed Jul 31, 2024
1 parent 0f37111 commit 8f9fb5c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
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)
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:
logger.debug("failed to check if azure-cli-core is installed as editable: %s", ex)
return False
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
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 "
"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

0 comments on commit 8f9fb5c

Please sign in to comment.