{AKS} az aks alert-config: Add commands to manage alert configurations - #10155
{AKS} az aks alert-config: Add commands to manage alert configurations#10155Matheus Mortatti (mamortat) wants to merge 6 commits into
az aks alert-config: Add commands to manage alert configurations#10155Conversation
|
Hi Matheus Mortatti (@mamortat), |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Adds a new az aks alert-config command group to the aks-preview extension to manage the AKS alertConfigurations child resource (API version 2026-05-02-preview), including client-side validation, table output formatting, and tests.
Changes:
- Introduces
az aks alert-config add|update|delete|show|listcommands wired to the vendoredAlertConfigurationsOperations. - Adds
--action-group-idvalidation and table transformers for list/show output. - Adds unit tests for validators/formatting/internal request shaping and a scenario test covering add→show→list→update→delete.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/aks-preview/HISTORY.rst | Adds a Pending changelog entry for the new command group. |
| src/aks-preview/azext_aks_preview/alertconfiguration.py | Implements internal add/update helpers that construct the SDK models and perform PUT semantics. |
| src/aks-preview/azext_aks_preview/_client_factory.py | Adds a client factory for alert_configurations. |
| src/aks-preview/azext_aks_preview/commands.py | Registers the new aks alert-config command group and hooks up custom commands + table transformers. |
| src/aks-preview/azext_aks_preview/custom.py | Adds custom wrappers for alert-config add/update/delete/show/list. |
| src/aks-preview/azext_aks_preview/_params.py | Registers arguments for aks alert-config including enum --mode and validator for --action-group-id. |
| src/aks-preview/azext_aks_preview/_validators.py | Adds validate_action_group_id to enforce Microsoft.Insights/actionGroups resource IDs. |
| src/aks-preview/azext_aks_preview/_format.py | Adds table transformers for alert-config show/list. |
| src/aks-preview/azext_aks_preview/_help.py | Adds help text and examples for the new command group and commands. |
| src/aks-preview/azext_aks_preview/tests/latest/test_alert_configuration.py | Adds unit tests for validator behavior, table formatting tolerance, and add/update internal request construction. |
| src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py | Adds a scenario test for the new commands (live/recorded test flow). |
| @AllowLargeResponse() | ||
| @AKSCustomResourceGroupPreparer( | ||
| random_name_length=17, name_prefix="clitest", location="eastus" | ||
| ) | ||
| def test_aks_alert_config_cmds(self, resource_group, resource_group_location): |
| merged_mode = mode if mode is not None else existing_mode | ||
| merged_action_group_id = ( | ||
| action_group_id if action_group_id is not None else existing_action_group_id | ||
| ) |
There was a problem hiding this comment.
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
| merged_mode = mode if mode is not None else existing_mode | ||
| merged_action_group_id = ( | ||
| action_group_id if action_group_id is not None else existing_action_group_id | ||
| ) |
There was a problem hiding this comment.
| # recorded yet. A recording-based test will replace this once the feature is enabled more | ||
| # broadly. | ||
| @live_only() | ||
| def test_aks_alert_config_cmds(self, resource_group, resource_group_location): |
There was a problem hiding this comment.
Can you provide proof that the test could pass in a dedicated sub? Or you may re-queue this live test pipeline with pipeline variables set to your sub.
https://dev.azure.com/msazure/CloudNativeCompute/_build/results?buildId=174242178&view=results
There was a problem hiding this comment.
I had to merge a fix on the RP before being able to do it, but now I'm having issues recording the tests due to the pypi block we have now. I'm working on it
Add the `az aks alert-config` command group to the aks-preview extension, exposing the alertConfigurations child resource introduced in API version 2026-05-02-preview. Commands: az aks alert-config add/update/delete/show/list The resource has two writable properties, mode (Managed|Disabled) and notification.actionGroupId. Since the API is PUT-only and both properties are required, `update` performs a read-modify-write so callers can change one property at a time. `--action-group-id` is optional and always emitted (as an empty string when unset) to satisfy the required-key contract; an explicit empty string clears it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The alertConfigurations RP endpoint is only deployed to selected regions. Pin the scenario test to eastus2euap and set preserve_default_location so AZURE_CLI_TEST_DEV_RESOURCE_GROUP_LOCATION cannot silently redirect the recording run to a region that rejects the requests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The AlertConfigurationPreview AFEC feature flag must be registered on the test subscription and the RP-side toggle must be active. Both are limited to eastus2euap/centraluseuap on allow-listed subscriptions today, so the scenario cannot be recorded yet. Without a cassette the test would evaluate in_recording as true and attempt a live run in CI, so mark it live_only until the feature is enabled more broadly and a recording can be added. This matches the existing treatment of test_aks_create_and_update_with_managed_nat_gateway_v2. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A live run with the AlertConfigurationPreview flag registered got past the feature gate but failed on the create call: the RP returns 202 for PUT alertConfigurations, while the swagger declares only 200/201 for that operation. The generated SDK therefore treats the 202 as an error and fails deserializing the empty body. Record the blocker in the live_only comment so the marker can be removed once the spec and RP agree and the SDK is re-vendored. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
9381744 to
a308491
Compare
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
The RP contract issue is resolved: PUT alertConfigurations now returns 201 on create and 200 on update, both with the resource body and the Azure-AsyncOperation header, verified live in eastus2euap against api-version 2026-05-02-preview. The scenario test still has no cassette, so it stays live_only to avoid attempting a live run in CI. Update the comment so it reflects the actual remaining blocker rather than the now-fixed status code mismatch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
Document that the recording toolchain works through the internal package proxy and that the remaining blocker is the RP cross-tenant token failure. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 2 pipeline(s). |
🤖 PR Validation —⚠️ Review suggested
This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
az aks alert-config add|update|delete|show|listDescription
Adds the
az aks alert-configcommand group to theaks-previewextension, exposing thealertConfigurationschild resource introduced in API version2026-05-02-preview(spec: Azure/azure-rest-api-specs#44598).
The vendored SDK already ships
AlertConfigurationsOperationsas of #10143, so this PR ispurely the command surface.
Implementation follows the existing
az aks jwtauthenticatorpattern.Design notes
The resource has two writable properties,
modeandnotification.actionGroupId. Per theswagger,
properties.required = [mode, notification]andAlertNotification.required = [actionGroupId].--action-group-idis optional. Thenotificationobject is always emitted, withactionGroupIdset to the supplied value or"", so the required key is never absent.The RP accepts an empty value.
updateperforms a read-modify-write. The API is PUT-only and both properties arerequired, so
updateGETs the existing configuration and merges, letting callers changeone property at a time. An omitted
--action-group-idpreserves the current value; anexplicit
--action-group-id ""clears it.updateon a missing configuration raisesResourceNotFoundErrorpointing ataz aks alert-config addrather than silently creating one.--action-group-idis validated client-side to be aMicrosoft.Insights/actionGroupsresource ID before any network call.Validation
azdev style aks-previewazdev linter --include-whl-extensions aks-previewpython scripts/ci/test_index.py -qeastus2euapThe test suite includes 279 passing unit tests, including 25 new tests in
test_alert_configuration.py. The command table, argument registry, validators, serializedrequest bodies, read-modify-write behavior, and action-group clearing behavior are covered.
Replay-test limitation
test_aks_alert_config_cmdsexercises add → show → list → update → delete and is pinned toeastus2euapwithpreserve_default_location=True.The original response-contract issue is fixed: create returns
201, update returns200,and both responses match the vendored SDK contract. The local toolchain was successfully
created using
https://packagefeedproxy.microsoft.io/pypi/simple/; all 25 targeted unittests pass and the scenario enters recording mode.
The current blocker is in the RP operation itself. After the cluster reaches
Succeeded,alert-config addfails because the RP attempts the managed-resource-group lookup with atoken issued by a different tenant than the subscription. Until that service-side issue is
resolved, the scenario is explicitly
@live_only()and the unit-test coverage remains theCI safety net.
Per the guidance block at the top of
HISTORY.rst, this PR adds an entry underPendingwithout bumping
VERSIONinsetup.py.