Skip to content

[AKS] az aks maintenanceconfiguration add/update: Add support for maintenanceWindow format in default maintenance configuration#33431

Open
anushkasingh16 wants to merge 1 commit into
Azure:devfrom
anushkasingh16:anushkasingh/default-mtc-maintenancewindow
Open

[AKS] az aks maintenanceconfiguration add/update: Add support for maintenanceWindow format in default maintenance configuration#33431
anushkasingh16 wants to merge 1 commit into
Azure:devfrom
anushkasingh16:anushkasingh/default-mtc-maintenancewindow

Conversation

@anushkasingh16
Copy link
Copy Markdown
Contributor

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

# New: Create default maintenance config using maintenanceWindow format
az aks maintenanceconfiguration add -g MyResourceGroup --cluster-name myCluster \
  -n default --schedule-type Weekly --day-of-week Monday --interval-weeks 1 \
  --duration 4 --start-time 09:00

# Still works: Legacy timeInWeek format
az aks maintenanceconfiguration add -g MyResourceGroup --cluster-name myCluster \
  -n default --weekday Monday --start-hour 1

# Error: Invalid schedule type for default (only Weekly allowed)
az aks maintenanceconfiguration add -g MyResourceGroup --cluster-name myCluster \
  -n default --schedule-type Daily --interval-days 3 --duration 4 --start-time 09:00

# Error: Cannot mix --weekday/--start-hour with --schedule-type
az aks maintenanceconfiguration add -g MyResourceGroup --cluster-name myCluster \
  -n default --weekday Monday --start-hour 1 --schedule-type Weekly

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.

Copilot AI review requested due to automatic review settings May 22, 2026 22:05
@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented May 22, 2026

️✔️AzureCLI-FullTest
️✔️acr
️✔️latest
️✔️3.12
️✔️3.13
️✔️acs
️✔️latest
️✔️3.12
️✔️3.13
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.13
️✔️ams
️✔️latest
️✔️3.12
️✔️3.13
️✔️apim
️✔️latest
️✔️3.12
️✔️3.13
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.13
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️aro
️✔️latest
️✔️3.12
️✔️3.13
️✔️backup
️✔️latest
️✔️3.12
️✔️3.13
️✔️batch
️✔️latest
️✔️3.12
️✔️3.13
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.13
️✔️billing
️✔️latest
️✔️3.12
️✔️3.13
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.13
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.13
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.13
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.13
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.13
️✔️config
️✔️latest
️✔️3.12
️✔️3.13
️✔️configure
️✔️latest
️✔️3.12
️✔️3.13
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.13
️✔️container
️✔️latest
️✔️3.12
️✔️3.13
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.13
️✔️core
️✔️latest
️✔️3.12
️✔️3.13
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.13
️✔️databoxedge
️✔️latest
️✔️3.12
️✔️3.13
️✔️dls
️✔️latest
️✔️3.12
️✔️3.13
️✔️dms
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.13
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.13
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.13
️✔️find
️✔️latest
️✔️3.12
️✔️3.13
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.13
️✔️identity
️✔️latest
️✔️3.12
️✔️3.13
️✔️iot
️✔️latest
️✔️3.12
️✔️3.13
️✔️keyvault
️✔️latest
️✔️3.12
️✔️3.13
️✔️lab
️✔️latest
️✔️3.12
️✔️3.13
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.13
️✔️maps
️✔️latest
️✔️3.12
️✔️3.13
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.13
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.13
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.13
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.13
️✔️network
️✔️latest
️✔️3.12
️✔️3.13
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.13
️✔️postgresql
️✔️latest
️✔️3.12
️✔️3.13
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.13
️✔️profile
️✔️latest
️✔️3.12
️✔️3.13
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.13
️✔️redis
️✔️latest
️✔️3.12
️✔️3.13
️✔️relay
️✔️latest
️✔️3.12
️✔️3.13
️✔️resource
️✔️latest
️✔️3.12
️✔️3.13
️✔️role
️✔️latest
️✔️3.12
️✔️3.13
️✔️search
️✔️latest
️✔️3.12
️✔️3.13
️✔️security
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.13
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.13
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.13
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.13
️✔️sql
️✔️latest
️✔️3.12
️✔️3.13
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.13
️✔️storage
️✔️latest
️✔️3.12
️✔️3.13
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.13
️✔️telemetry
️✔️latest
️✔️3.12
️✔️3.13
️✔️util
️✔️latest
️✔️3.12
️✔️3.13
️✔️vm
️✔️latest
️✔️3.12
️✔️3.13

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @anushkasingh16,
Since the current milestone time is less than 7 days, this pr will be reviewed in the next milestone.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd Bot commented May 22, 2026

️✔️AzureCLI-BreakingChangeTest
️✔️Non Breaking Changes

Copy link
Copy Markdown
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

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 Weekly for default maintenance configuration and construct maintenance_window payload.
  • Add negative tests validating default-config argument constraints for --schedule-type and --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.

Comment on lines +62 to +77
# 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
Comment on lines +71 to +75
maintenance_configuration_models = AKSManagedClusterModels(cmd, ResourceType.MGMT_CONTAINERSERVICE).maintenance_configuration_models
Result = (
maintenance_configuration_models.MaintenanceConfiguration
)
result = Result()
@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 22, 2026

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

@github-actions
Copy link
Copy Markdown

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>

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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_weeks to 1 here when missing (raw_parameters["interval_weeks"] = 1) before calling constructMaintenanceWindow, 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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@yewmsft
Copy link
Copy Markdown
Member

yewmsft commented May 23, 2026

nit: validation gap — for default config with --schedule-type Weekly, you reject interval_weeks != 1 but pass other maintenanceWindow params (utc_offset, not_allowed_dates, start_date) through to constructMaintenanceWindow unchecked. if the RP rejects those for the default config (or silently ignores them), the user gets a confusing failure / wrong behavior. either enumerate the supported subset and reject the rest up-front with a clear error, or confirm the RP-side surface and document it in _help.py.

also the example text says "in UTC every week" but the maintenanceWindow path supports --utc-offset. clarify whether default-config maintenanceWindow honors offset or ignores it.

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

Labels

act-observability-squad AKS az aks/acs/openshift Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants