From 765f17f9a36d84c0eea9774d0b323982e5f5e82b Mon Sep 17 00:00:00 2001 From: Amol Agrawal Date: Wed, 13 Jul 2022 16:01:35 -0700 Subject: [PATCH 1/2] add omsagent rename changes --- .../partner_extensions/ContainerInsights.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index 0db8b5dbed..abe9d23fb9 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -87,10 +87,15 @@ def Delete(self, cmd, client, resource_group_name, cluster_name, name, cluster_t cluster_resource_id = '/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}'.format(subscription_id, resource_group_name, cluster_rp, cluster_type, cluster_name) if (extension is not None) and (extension.configuration_settings is not None): configSettings = extension.configuration_settings + # omsagent is being renamed to ama-logs. Check for both for compatibility if 'omsagent.useAADAuth' in configSettings: useAADAuthSetting = configSettings['omsagent.useAADAuth'] if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting): useAADAuth = True + elif 'amalogs.useAADAuth' in configSettings: + useAADAuthSetting = configSettings['amalogs.useAADAuth'] + if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting): + useAADAuth = True if useAADAuth: association_url = cmd.cli_ctx.cloud.endpoints.resource_manager + f"{cluster_resource_id}/providers/Microsoft.Insights/dataCollectionRuleAssociations/ContainerInsightsExtension?api-version=2021-04-01" for _ in range(3): @@ -453,11 +458,18 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_n if 'logAnalyticsWorkspaceResourceID' in configuration_settings: workspace_resource_id = configuration_settings['logAnalyticsWorkspaceResourceID'] + # omsagent is being renamed to ama-logs. Check for both for compatibility if 'omsagent.useAADAuth' in configuration_settings: useAADAuthSetting = configuration_settings['omsagent.useAADAuth'] logger.info("provided useAADAuth flag is : %s", useAADAuthSetting) if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting): useAADAuth = True + elif 'amalogs.useAADAuth' in configuration_settings: + useAADAuthSetting = configuration_settings['amalogs.useAADAuth'] + logger.info("provided useAADAuth flag is : %s", useAADAuthSetting) + if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting): + useAADAuth = True + workspace_resource_id = workspace_resource_id.strip() @@ -473,7 +485,9 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_n 'proxyEndpoint url should in this format http(s)://:@:' ) logger.info("successfully validated proxyEndpoint url hence passing proxy endpoint to extension") + # omsagent is being renamed to ama-logs. Set for both for compatibility configuration_protected_settings['omsagent.proxy'] = configuration_protected_settings['proxyEndpoint'] + configuration_protected_settings['amalogs.proxy'] = configuration_protected_settings['proxyEndpoint'] if not workspace_resource_id: workspace_resource_id = _ensure_default_log_analytics_workspace_for_monitoring( @@ -509,20 +523,28 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_n if not shared_keys: raise InvalidArgumentValueError('Failed to retrieve shared key for workspace {}'.format( log_analytics_workspace)) + # omsagent is being renamed to ama-logs. Set for both for compatibility configuration_protected_settings['omsagent.secret.key'] = shared_keys.primary_shared_key + configuration_protected_settings['amalogs.secret.key'] = shared_keys.primary_shared_key + # omsagent is being renamed to ama-logs. Set for both for compatibility configuration_protected_settings['omsagent.secret.wsid'] = log_analytics_workspace.customer_id + configuration_protected_settings['amalogs.secret.wsid'] = log_analytics_workspace.customer_id configuration_settings['logAnalyticsWorkspaceResourceID'] = workspace_resource_id # set the domain for the ci agent for non azure public clouds cloud_name = cmd.cli_ctx.cloud.name if cloud_name.lower() == 'azurechinacloud': configuration_settings['omsagent.domain'] = 'opinsights.azure.cn' + configuration_settings['amalogs.domain'] = 'opinsights.azure.cn' elif cloud_name.lower() == 'azureusgovernment': configuration_settings['omsagent.domain'] = 'opinsights.azure.us' + configuration_settings['amalogs.domain'] = 'opinsights.azure.us' elif cloud_name.lower() == 'usnat': configuration_settings['omsagent.domain'] = 'opinsights.azure.eaglex.ic.gov' + configuration_settings['amalogs.domain'] = 'opinsights.azure.eaglex.ic.gov' elif cloud_name.lower() == 'ussec': configuration_settings['omsagent.domain'] = 'opinsights.azure.microsoft.scloud' + configuration_settings['amalogs.domain'] = 'opinsights.azure.microsoft.scloud' def get_existing_container_insights_extension_dcr_tags(cmd, dcr_url): From 1d35fd658e732bb45c629445514ec67e0dffa98c Mon Sep 17 00:00:00 2001 From: Amol Agrawal Date: Wed, 13 Jul 2022 16:39:17 -0700 Subject: [PATCH 2/2] fix flake8 errors --- .../azext_k8s_extension/partner_extensions/ContainerInsights.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py index abe9d23fb9..bd7a366886 100644 --- a/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py +++ b/src/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py @@ -469,7 +469,6 @@ def _get_container_insights_settings(cmd, cluster_resource_group_name, cluster_n logger.info("provided useAADAuth flag is : %s", useAADAuthSetting) if (isinstance(useAADAuthSetting, str) and str(useAADAuthSetting).lower() == "true") or (isinstance(useAADAuthSetting, bool) and useAADAuthSetting): useAADAuth = True - workspace_resource_id = workspace_resource_id.strip()