Skip to content

Commit

Permalink
Merge branch 'main' into adsandor/pubip
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandido authored Oct 22, 2024
2 parents f94e82b + 73c2d05 commit db1ebf6
Show file tree
Hide file tree
Showing 120 changed files with 7,660 additions and 1,885 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ If there is no rush to release a new version, please just add a description of t

To release a new version, please select a new version number (usually plus 1 to last patch version, X.Y.Z -> Major.Minor.Patch, more details in `\doc <https://semver.org/>`_), and then add a new section named as the new version number in this file, the content should include the new modifications and everything from the *Pending* section. Finally, update the `VERSION` variable in `setup.py` with this new version number.

9.0.0b7
+++++++
* Fix bug related to updating the monitoring addon DCR when the non monitoring addon enabled through `az aks enable-addons`.

9.0.0b6
+++++++
* Print warning message when new node pool is created with SSH enabled, suggest to create SSH disabled node pool.
Expand Down
28 changes: 28 additions & 0 deletions src/aks-preview/azext_aks_preview/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
get_mc_snapshots_client,
get_nodepool_snapshots_client,
)

from azext_aks_preview._consts import (
ADDONS,
CONST_MONITORING_ADDON_NAME
)

from azure.cli.command_modules.acs._helpers import map_azure_error_to_cli_error
from azure.cli.command_modules.acs._validators import extract_comma_separated_string
from azure.cli.core.azclierror import (
Expand Down Expand Up @@ -346,3 +352,25 @@ def check_is_azure_cli_core_editable_installed():
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


def check_is_monitoring_addon_enabled(addons, instance):
is_monitoring_addon_enabled = False
is_monitoring_addon = False
try:
addon_args = addons.split(',')
for addon_arg in addon_args:
if addon_arg in ADDONS:
addon = ADDONS[addon_arg]
if addon == CONST_MONITORING_ADDON_NAME:
is_monitoring_addon = True
break
addon_profiles = instance.addon_profiles or {}
is_monitoring_addon_enabled = (
is_monitoring_addon
and CONST_MONITORING_ADDON_NAME in addon_profiles
and addon_profiles[CONST_MONITORING_ADDON_NAME].enabled
)
except Exception as ex: # pylint: disable=broad-except
logger.debug("failed to check monitoring addon enabled: %s", ex)
return is_monitoring_addon_enabled
11 changes: 7 additions & 4 deletions src/aks-preview/azext_aks_preview/addonconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
sanitize_loganalytics_ws_resource_id,
ensure_default_log_analytics_workspace_for_monitoring
)
from azext_aks_preview._helpers import (
check_is_monitoring_addon_enabled,
)

from azext_aks_preview._client_factory import CUSTOM_MGMT_AKS_PREVIEW
from azext_aks_preview._roleassignments import add_role_assignment
from azext_aks_preview._consts import (
Expand Down Expand Up @@ -108,8 +112,9 @@ def enable_addons(
dns_zone_resource_ids=dns_zone_resource_ids
)

if CONST_MONITORING_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
CONST_MONITORING_ADDON_NAME].enabled:
monitoring_addon_enabled = check_is_monitoring_addon_enabled(addons, instance)

if monitoring_addon_enabled:
if CONST_MONITORING_USING_AAD_MSI_AUTH in instance.addon_profiles[CONST_MONITORING_ADDON_NAME].config and \
str(instance.addon_profiles[CONST_MONITORING_ADDON_NAME].config[
CONST_MONITORING_USING_AAD_MSI_AUTH]).lower() == 'true':
Expand Down Expand Up @@ -152,8 +157,6 @@ def enable_addons(
data_collection_settings=data_collection_settings
)

monitoring_addon_enabled = CONST_MONITORING_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
CONST_MONITORING_ADDON_NAME].enabled
ingress_appgw_addon_enabled = CONST_INGRESS_APPGW_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
CONST_INGRESS_APPGW_ADDON_NAME].enabled

Expand Down
14 changes: 9 additions & 5 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
get_nodepool_snapshot_by_snapshot_id,
print_or_merge_credentials,
process_message_for_run_command,
check_is_monitoring_addon_enabled,
)
from azext_aks_preview._podidentity import (
_ensure_managed_identity_operator_permission,
Expand Down Expand Up @@ -2146,9 +2147,10 @@ def aks_enable_addons(
dns_zone_resource_id=dns_zone_resource_id,
dns_zone_resource_ids=dns_zone_resource_ids,
)

is_monitoring_addon_enabled = check_is_monitoring_addon_enabled(addons, instance)
if (
CONST_MONITORING_ADDON_NAME in instance.addon_profiles and
instance.addon_profiles[CONST_MONITORING_ADDON_NAME].enabled
is_monitoring_addon_enabled
):
if (
CONST_MONITORING_USING_AAD_MSI_AUTH in
Expand Down Expand Up @@ -2201,8 +2203,6 @@ def aks_enable_addons(
aad_route=False,
)

monitoring = CONST_MONITORING_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
CONST_MONITORING_ADDON_NAME].enabled
ingress_appgw_addon_enabled = CONST_INGRESS_APPGW_ADDON_NAME in instance.addon_profiles and instance.addon_profiles[
CONST_INGRESS_APPGW_ADDON_NAME].enabled

Expand All @@ -2211,7 +2211,11 @@ def aks_enable_addons(
if CONST_VIRTUAL_NODE_ADDON_NAME + os_type in instance.addon_profiles:
enable_virtual_node = True

need_post_creation_role_assignment = monitoring or ingress_appgw_addon_enabled or enable_virtual_node
need_post_creation_role_assignment = (
is_monitoring_addon_enabled or
ingress_appgw_addon_enabled or
enable_virtual_node
)
if need_post_creation_role_assignment:
# adding a wait here since we rely on the result for role assignment
result = LongRunningOperation(cmd.cli_ctx)(
Expand Down
Loading

0 comments on commit db1ebf6

Please sign in to comment.