[AKS] az aks maintenanceconfiguration add/update: Add support for maintenanceWindow format in default maintenance configuration#33431
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @anushkasingh16, |
️✔️AzureCLI-BreakingChangeTest
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Enable --schedule-type (Weekly-only) for the default AKS maintenance configuration using the maintenanceWindow format, and update CLI help/docs and tests accordingly.
Changes:
- Allow
--schedule-type Weeklyfor default maintenance configuration and constructmaintenance_windowpayload. - Add negative tests validating default-config argument constraints for
--schedule-typeand--interval-weeks. - Update parameter/help text and add CLI examples for default maintenanceWindow schedules.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py | Adds schedule_type handling for default config and builds maintenance_window model |
| src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_maintenanceconfiguration.py | Updates/extends tests for default config schedule-type validation |
| src/azure-cli/azure/cli/command_modules/acs/_params.py | Clarifies --schedule-type help now that default supports Weekly |
| src/azure-cli/azure/cli/command_modules/acs/_help.py | Adds examples and updates help text to mention default Weekly-only support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # If schedule_type is provided, use maintenanceWindow format for the default config | ||
| if schedule_type is not None: | ||
| raise MutuallyExclusiveArgumentError('--schedule-type is not supported for default maintenance configuration.') | ||
| if weekday is not None or start_hour is not None: | ||
| raise MutuallyExclusiveArgumentError('--weekday and --start-hour cannot be used together with --schedule-type for default maintenance configuration.') | ||
| if schedule_type != CONST_WEEKLY_MAINTENANCE_SCHEDULE: | ||
| raise InvalidArgumentValueError('--schedule-type for default maintenance configuration must be Weekly.') | ||
| interval_weeks = raw_parameters.get("interval_weeks") | ||
| if interval_weeks is not None and interval_weeks != 1: | ||
| raise InvalidArgumentValueError('--interval-weeks for default maintenance configuration must be 1.') | ||
| maintenance_configuration_models = AKSManagedClusterModels(cmd, ResourceType.MGMT_CONTAINERSERVICE).maintenance_configuration_models | ||
| Result = ( | ||
| maintenance_configuration_models.MaintenanceConfiguration | ||
| ) | ||
| result = Result() | ||
| result.maintenance_window = constructMaintenanceWindow(cmd, raw_parameters) | ||
| return result |
| maintenance_configuration_models = AKSManagedClusterModels(cmd, ResourceType.MGMT_CONTAINERSERVICE).maintenance_configuration_models | ||
| Result = ( | ||
| maintenance_configuration_models.MaintenanceConfiguration | ||
| ) | ||
| result = Result() |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
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). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
| interval_weeks = raw_parameters.get("interval_weeks") | ||
| if interval_weeks is not None and interval_weeks != 1: | ||
| raise InvalidArgumentValueError('--interval-weeks for default maintenance configuration must be 1.') | ||
| maintenance_configuration_models = AKSManagedClusterModels(cmd, ResourceType.MGMT_CONTAINERSERVICE).maintenance_configuration_models |
There was a problem hiding this comment.
interval_weeks=None slips past the default-config validation.
The current check only rejects interval_weeks != 1 when it is explicitly provided:
if interval_weeks is not None and interval_weeks != 1:
raise InvalidArgumentValueError('--interval-weeks for default maintenance configuration must be 1.')If a user runs az aks maintenanceconfiguration add ... -n default --schedule-type Weekly --day-of-week Monday --duration 4 --start-time 09:00 (omitting --interval-weeks), they fall through to constructWeeklySchedule, which then raises:
Please specify --interval-weeks and --day-of-week when using weekly schedule.
That's a confusing error for the default-config flow where the value is forced to 1 anyway. Suggest one of:
- Default
interval_weeksto1here when missing (raw_parameters["interval_weeks"] = 1) before callingconstructMaintenanceWindow, so the user doesn't have to pass it; or - Make the message explicit:
if interval_weeks != 1: raise InvalidArgumentValueError(...)so omission is also caught with the default-config-specific message.
The first option matches the RP contract better (only 1 is valid) and reduces friction.
| - name: --schedule-type | ||
| type: string | ||
| short-summary: Choose either 'Daily', 'Weekly', 'AbsoluteMonthly' or 'RelativeMonthly' for your maintenance schedule. Only applicable to 'aksManagedAutoUpgradeSchedule' and 'aksManagedNodeOSUpgradeSchedule' maintenance configuration. | ||
| short-summary: Choose either 'Daily', 'Weekly', 'AbsoluteMonthly' or 'RelativeMonthly' for your maintenance schedule. For default maintenance configuration, only 'Weekly' is supported. |
There was a problem hiding this comment.
Help text for --schedule-type is now inconsistent with --start-hour / --weekday help.
This line now says --schedule-type is supported for default config (Weekly only), but the help for --weekday and --start-hour (a few lines above, e.g. line 1626) still says Applicable to default maintenance configuration only. without mentioning that the maintenanceWindow path is now the preferred way to configure default. Consider a short note on those two flags pointing users to --schedule-type Weekly as the modern alternative — otherwise users hitting --help won't discover the new path.
|
nit: validation gap — for default config with also the example text says "in UTC every week" but the maintenanceWindow path supports |
Related command
az aks maintenanceconfiguration add
az aks maintenanceconfiguration update
Description
Previously, the default maintenance configuration only supported the legacy timeInWeek format (using --weekday and --start-hour).
The AKS RP API (since 2023-05-01) also supports the maintenanceWindow format for the default config, but the CLI was blocking it by raising an error when --schedule-type was provided for the default config.
This PR removes that restriction and allows users to use --schedule-type Weekly with the default maintenance configuration name, which routes to the maintenanceWindow format. The RP enforces that only Weekly schedule with intervalWeeks=1 is valid for the default config (since API version 2025-03-01), so the CLI validates this client-side as well.
The legacy --weekday --start-hour path continues to work unchanged for backward compatibility.
Testing Guide
History Notes
[AKS] az aks maintenanceconfiguration add/update: Add --schedule-type Weekly support for default maintenance configuration using the maintenanceWindow format
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.