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} Monitoring addon MSI auth - update API version for DCR and stream group #22960

Merged
merged 10 commits into from
Jun 28, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,10 @@ def ensure_container_insights_for_monitoring(
region_ids = map(
lambda x: region_names_to_id[x], resource["locations"])
if cluster_region not in region_ids:
raise ClientRequestError(f"Data Collection Rule Associations are not supported for cluster region {cluster_region}")
raise ClientRequestError(
f"Data Collection Rule Associations are not supported for cluster region {cluster_region}")
dcr_url = cmd.cli_ctx.cloud.endpoints.resource_manager + \
f"{dcr_resource_id}?api-version=2019-11-01-preview"
f"{dcr_resource_id}?api-version=2021-04-01"
# get existing tags on the container insights extension DCR if the customer added any
existing_tags = get_existing_container_insights_extension_dcr_tags(
cmd, dcr_url)
Expand All @@ -394,18 +395,7 @@ def ensure_container_insights_for_monitoring(
{
"name": "ContainerInsightsExtension",
"streams": [
"Microsoft-Perf",
"Microsoft-ContainerInventory",
"Microsoft-ContainerLog",
"Microsoft-ContainerLogV2",
"Microsoft-ContainerNodeInventory",
"Microsoft-KubeEvents",
"Microsoft-KubeMonAgentEvents",
"Microsoft-KubeNodeInventory",
"Microsoft-KubePodInventory",
"Microsoft-KubePVInventory",
"Microsoft-KubeServices",
"Microsoft-InsightsMetrics",
"Microsoft-ContainerInsights-Group-Default"
],
"extensionName": "ContainerInsights",
}
Expand All @@ -414,18 +404,7 @@ def ensure_container_insights_for_monitoring(
"dataFlows": [
{
"streams": [
"Microsoft-Perf",
"Microsoft-ContainerInventory",
"Microsoft-ContainerLog",
"Microsoft-ContainerLogV2",
"Microsoft-ContainerNodeInventory",
"Microsoft-KubeEvents",
"Microsoft-KubeMonAgentEvents",
"Microsoft-KubeNodeInventory",
"Microsoft-KubePodInventory",
"Microsoft-KubePVInventory",
"Microsoft-KubeServices",
"Microsoft-InsightsMetrics",
"Microsoft-ContainerInsights-Group-Default"
],
"destinations": ["la-workspace"],
}
Expand Down Expand Up @@ -465,7 +444,7 @@ def ensure_container_insights_for_monitoring(
}
)
association_url = cmd.cli_ctx.cloud.endpoints.resource_manager + \
f"{cluster_resource_id}/providers/Microsoft.Insights/dataCollectionRuleAssociations/ContainerInsightsExtension?api-version=2019-11-01-preview"
f"{cluster_resource_id}/providers/Microsoft.Insights/dataCollectionRuleAssociations/ContainerInsightsExtension?api-version=2021-04-01"
for _ in range(3):
try:
send_raw_request(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6533,14 +6533,14 @@ def create_new_cluster_with_monitoring_aad_auth(self, resource_group, resource_g
# check that the DCR was created
dataCollectionRuleName = f"MSCI-{aks_name}-{resource_group_location}"
dcr_resource_id = f"/subscriptions/{subscription}/resourceGroups/{workspace_resource_group}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"
get_cmd = f'rest --method get --url https://management.azure.com{dcr_resource_id}?api-version=2019-11-01-preview'
get_cmd = f'rest --method get --url https://management.azure.com{dcr_resource_id}?api-version=2021-04-01'
self.cmd(get_cmd, checks=[
self.check('properties.destinations.logAnalytics[0].workspaceResourceId', f'{workspace_resource_id}')
])

# check that the DCR-A was created
dcra_resource_id = f"{cluster_resource_id}/providers/Microsoft.Insights/dataCollectionRuleAssociations/ContainerInsightsExtension"
get_cmd = f'rest --method get --url https://management.azure.com{dcra_resource_id}?api-version=2019-11-01-preview'
get_cmd = f'rest --method get --url https://management.azure.com{dcra_resource_id}?api-version=2021-04-01'
self.cmd(get_cmd, checks=[
self.check('properties.dataCollectionRuleId', f'{dcr_resource_id}')
])
Expand Down Expand Up @@ -6606,14 +6606,14 @@ def enable_monitoring_existing_cluster_aad_auth(self, resource_group, resource_g
# check that the DCR was created
dataCollectionRuleName = f"MSCI-{aks_name}-{resource_group_location}"
dcr_resource_id = f"/subscriptions/{subscription}/resourceGroups/{workspace_resource_group}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"
get_cmd = f'rest --method get --url https://management.azure.com{dcr_resource_id}?api-version=2019-11-01-preview'
get_cmd = f'rest --method get --url https://management.azure.com{dcr_resource_id}?api-version=2021-04-01'
self.cmd(get_cmd, checks=[
self.check('properties.destinations.logAnalytics[0].workspaceResourceId', f'{workspace_resource_id}')
])

# check that the DCR-A was created
dcra_resource_id = f"{cluster_resource_id}/providers/Microsoft.Insights/dataCollectionRuleAssociations/ContainerInsightsExtension"
get_cmd = f'rest --method get --url https://management.azure.com{dcra_resource_id}?api-version=2019-11-01-preview'
get_cmd = f'rest --method get --url https://management.azure.com{dcra_resource_id}?api-version=2021-04-01'
self.cmd(get_cmd, checks=[
self.check('properties.dataCollectionRuleId', f'{dcr_resource_id}')
])
Expand Down Expand Up @@ -6660,7 +6660,7 @@ def test_aks_create_with_monitoring_legacy_auth(self, resource_group, resource_g
# check that the DCR was created
dataCollectionRuleName = f"MSCI-{aks_name}-{resource_group_location}"
dcr_resource_id = f"/subscriptions/{subscription}/resourceGroups/{workspace_resource_group}/providers/Microsoft.Insights/dataCollectionRules/{dataCollectionRuleName}"
get_cmd = f'rest --method get --url https://management.azure.com{dcr_resource_id}?api-version=2019-11-01-preview'
get_cmd = f'rest --method get --url https://management.azure.com{dcr_resource_id}?api-version=2021-04-01'
self.cmd(get_cmd, checks=[
self.check('properties.destinations.logAnalytics[0].workspaceResourceId', f'{workspace_resource_id}')
])
Expand Down