Skip to content

Comments

[Managed Prometheus] Simplify logic and enable correct recording rule groups for managed prom#8796

Closed
bragi92 wants to merge 7 commits intoAzure:mainfrom
AzureArcForKubernetes:kaveesh/rr
Closed

[Managed Prometheus] Simplify logic and enable correct recording rule groups for managed prom#8796
bragi92 wants to merge 7 commits intoAzure:mainfrom
AzureArcForKubernetes:kaveesh/rr

Conversation

@bragi92
Copy link
Member

@bragi92 bragi92 commented May 27, 2025


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az k8s-extension create --name azuremonitor-metrics --cluster-name --resource-group --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

Copilot AI review requested due to automatic review settings May 27, 2025 22:13
@azure-client-tools-bot-prd
Copy link

Validation for Breaking Change Starting...

Thanks for your contribution!

@yonzhan
Copy link
Collaborator

yonzhan commented May 27, 2025

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Contributor

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR simplifies the logic for managed Prometheus by updating the recording rule groups and adds support for the new 'DisableInformerCache' configuration in the data protection module. Key changes include:

  • Updating test scripts and pipeline templates to support the new extension functionality.
  • Bumping the extension version from 1.6.4 to 1.6.5 and updating recording rule creation and deletion logic.
  • Adding support for the new 'DisableInformerCache' configuration in the DataProtectionKubernetes extension.

Reviewed Changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
testing/* New and updated PowerShell test suites, pipeline templates, and supporting files for validating the extension functionality.
src/k8s-extension/setup.py Extension version bump from 1.6.4 to 1.6.5.
src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/recordingrules/delete.py Added deletion for an additional UX recording rule group for improved recording rule management.
src/k8s-extension/azext_k8s_extension/partner_extensions/azuremonitormetrics/recordingrules/create.py Modified logic to iterate over filtered recording rule templates and call put_rules for non-Windows rules.
src/k8s-extension/azext_k8s_extension/partner_extensions/DataProtectionKubernetes.py Added support for the new “DisableInformerCache” configuration.
testing/Bootstrap.ps1 & testing/Test.ps1 Adjustments to resource group handling and test file path iteration in the CI workflow.
Comments suppressed due to low confidence (1)

testing/Test.ps1:82

  • $testFilePaths is assigned as a string when handling 'k8s-configuration' tests, but it is iterated over in a foreach loop as if it were a collection. Consider wrapping it in an array (e.g., @($testFilePaths)) or using it directly in Get-ChildItem.
foreach ($paths in $testFilePaths) {

Comment on lines +66 to +73
for index, rule_template in enumerate(default_rules_template):
rule_name = rule_template["name"]
is_windows_rule = "win" in rule_name.lower()

# Skip any recording rules as ARC metrics extension doesn't have windows support
if is_windows_rule:
continue

Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

When filtering out Windows rules using 'continue', the use of enumerate's index may not correctly correspond to the intended rule_template being processed. Consider collecting non-Windows templates in a separate list or directly using the current rule_template instead of default_rules_template[index] to avoid potential index mismatches.

Suggested change
for index, rule_template in enumerate(default_rules_template):
rule_name = rule_template["name"]
is_windows_rule = "win" in rule_name.lower()
# Skip any recording rules as ARC metrics extension doesn't have windows support
if is_windows_rule:
continue
# Filter out Windows rules into a separate list
non_windows_templates = [
rule_template for rule_template in default_rules_template
if "win" not in rule_template["name"].lower()
]
for rule_template in non_windows_templates:

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +34
az group show --name $envConfig.resourceGroup
if (!$?) {
Write-Host "Resource group does not exist, creating it now in region 'eastus2euap'"
az group create --name $envConfig.resourceGroup --location eastus2euap
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

The variable '$envConfig' is used instead of the correct '$ENVCONFIG' as defined earlier, which could lead to lookup failures. Update '$envConfig.resourceGroup' to '$ENVCONFIG.resourceGroup' for consistency.

Suggested change
az group show --name $envConfig.resourceGroup
if (!$?) {
Write-Host "Resource group does not exist, creating it now in region 'eastus2euap'"
az group create --name $envConfig.resourceGroup --location eastus2euap
az group show --name $ENVCONFIG.resourceGroup
if (!$?) {
Write-Host "Resource group does not exist, creating it now in region 'eastus2euap'"
az group create --name $ENVCONFIG.resourceGroup --location eastus2euap

Copilot uses AI. Check for mistakes.
@bragi92 bragi92 closed this May 27, 2025
@github-actions
Copy link
Contributor

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

@github-actions
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Auto-Assign Auto assign by bot Logic App

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants