Skip to content

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

Open
anushkasingh16 wants to merge 2 commits 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 2 commits into
Azure:devfrom
anushkasingh16:anushkasingh/default-mtc-maintenancewindow

Conversation

@anushkasingh16
Copy link
Copy Markdown
Contributor

@anushkasingh16 anushkasingh16 commented May 22, 2026

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
❌acs
rule cmd_name rule_message suggest_message
1007 - ParaRemove aks nodepool add cmd aks nodepool add removed parameter enable_artifact_streaming please add back parameter enable_artifact_streaming for cmd aks nodepool add
1010 - ParaPropUpdate aks nodepool add cmd aks nodepool add update parameter spot_max_price: updated property default from nan to nan please change property default from nan to nan for parameter spot_max_price of cmd aks nodepool add
1007 - ParaRemove aks nodepool update cmd aks nodepool update removed parameter disable_artifact_streaming please add back parameter disable_artifact_streaming for cmd aks nodepool update
1007 - ParaRemove aks nodepool update cmd aks nodepool update removed parameter enable_artifact_streaming please add back parameter enable_artifact_streaming for cmd aks nodepool update

Please submit your Breaking Change Pre-announcement ASAP if you haven't already. Please note:

  • Breaking changes can only be merged during the designated breaking change window
  • A pre-announcement must be released at least one month in advance

For more details on how to introduce breaking changes, refer to the documentation: azure-cli/doc/how_to_introduce_breaking_changes.md

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 thread src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acs/maintenanceconfiguration.py Outdated
@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>

Comment thread src/azure-cli/azure/cli/command_modules/acs/_help.py
@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.

@FumingZhang
Copy link
Copy Markdown
Member

FumingZhang commented May 25, 2026

@anushkasingh16 anushkasingh16 changed the title [AKS] az aks maintenanceconfiguration add/update: Add support for maintenanceWindow format in default maintenance configuration [AKS] az aks maintenanceconfiguration add/update: Add support for maintenanceWindow format in default maintenance configuration May 25, 2026
@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@FumingZhang
Copy link
Copy Markdown
Member

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@yewmsft
Copy link
Copy Markdown
Member

yewmsft commented May 26, 2026

prior threads addressed:

  • maintenanceconfiguration.py:73 — option 1 (enumerate & reject up-front) chosen for --interval-weeks/--interval-days/--interval-months/--day-of-month/--week-index. The explicit comment at lines 79-80 ("utc_offset and start_date are intentionally not validated here: the RP accepts the full MaintenanceWindow schema") cleanly answers the original RP-surface question, and not_allowed_dates falls under the same "pass through" decision. Good.
  • _help.py:1626/1634--weekday/--start-hour help now calls out the maintenanceWindow path as preferred (Ibrahim's thread).
  • Added a happy-path test that constructs a Weekly default config via --schedule-type. Suggest also adding a negative test for one of the new rejection branches (e.g. --schedule-type Weekly + --day-of-month → expect MutuallyExclusiveArgumentError) so the validation enumeration doesn't silently regress.

No vote.

@yewmsft
Copy link
Copy Markdown
Member

yewmsft commented May 29, 2026

Code review

What this PR does (as built)

Adds a maintenanceWindow-format path to constructDefaultMaintenanceConfiguration: when --schedule-type Weekly is passed for -n default, it builds a MaintenanceConfiguration with maintenance_window via the existing constructMaintenanceWindow helper. The legacy --weekday/--start-hour path is preserved unchanged. Help/params updated; 6 new tests added.

Suggested change in direction

This PR ships in a new CLI major version, so we have a one-time opportunity to stop emitting timeInWeek from the CLI entirely. Recommend dropping the legacy branch instead of keeping it side-by-side. Two options:

  1. Remove the flags outright (cleanest): delete --weekday and --start-hour from _params.py and _help.py, drop the legacy branch in constructDefaultMaintenanceConfiguration, and make the function unconditionally take the new maintenanceWindow path. Smallest surface area.
  2. Keep the flags but hard-reject with a clear error pointing to --schedule-type Weekly. Friendlier for users running old scripts, but you're keeping dead-flag plumbing.

Either way, the result is: after this CLI version ships, no CLI invocation can produce a timeInWeek default config. RP/templates still accept it for back-compat; existing cluster configs are unaffected.

Note this is a breaking change in az aks maintenanceconfiguration add/update -n default --weekday ... --start-hour .... Please call it out in the PR description / release notes and confirm release management is aligned.

Issues in the current code

1. Misleading error when --day-of-week is omitted (medium).
constructDefaultMaintenanceConfiguration doesn't validate day_of_week upfront. If a user passes --schedule-type Weekly --start-time 09:00 --duration 4 (no --day-of-week), execution reaches constructWeeklySchedule which raises "Please specify --interval-weeks and --day-of-week when using weekly schedule." — directly contradicting the new help text that forbids --interval-weeks for default. Validate day_of_week is not None in the default-config branch with a clearer message.

2. Mutation of caller's dict (low).

raw_parameters["interval_weeks"] = 1

mutates the dict the caller owns. Today nothing downstream re-reads it, but the function is presented as a pure "construct" function. Cleaner: pass interval_weeks=1 via a small helper, or copy the dict. At minimum add a comment.

3. Inconsistent exception types for similar rejections (low).
--interval-weeks rejection uses InvalidArgumentValueError; the --interval-days / --interval-months / --day-of-month / --week-index rejection uses MutuallyExclusiveArgumentError. Both are "you passed a flag that's not allowed in this combination." Pick one — MutuallyExclusiveArgumentError fits both.

4. Bulk error doesn't identify the offending flag (low).

if any(raw_parameters.get(p) is not None for p in ("interval_days", "interval_months", "day_of_month", "week_index")):
    raise MutuallyExclusiveArgumentError('--interval-days, --interval-months, --day-of-month and --week-index cannot be used ...')

User gets a kitchen-sink message. Trivial improvement:

offending = [p for p in (...) if raw_parameters.get(p) is not None]
if offending:
    flags = ", ".join("--" + p.replace("_", "-") for p in offending)
    raise MutuallyExclusiveArgumentError(f'{flags} cannot be used for default maintenance configuration.')

5. Cosmetic rename adds noise (low).
ResultMaintenanceConfiguration rename touches the legacy branch and constructDedicatedMaintenanceConfiguration, which are otherwise untouched by the feature. Either split into a separate cleanup commit or revert. Not blocking.

6. Help text length (nit).
--weekday and --start-hour short-summaries run ~250 chars each. Move the migration guidance to the examples block; keep short-summary short. (Moot if you remove the flags entirely per the recommendation above.)

7. DRY in tests (low).
MockMaintenanceConfigClient is defined twice inside the new tests. Hoist to setUp or module-level.

8. Missing test coverage (medium).
No test for "user forgot --day-of-week" — pin the user-facing message once #1 is fixed.

9. No test for --utc-offset / --start-date on default (low).
The added comment promises the RP accepts the full MaintenanceWindow schema (including these optional fields) for all config types. Add a test passing both and asserting they land on the constructed window, so a future model regen that drops them is caught.

Looks fine

  • CONST_WEEKLY_MAINTENANCE_SCHEDULE is already imported.
  • constructMaintenanceWindow already raises RequiredArgumentMissingError for missing --start-time / --duration — covered by reuse.
  • Renamed test still covers the "mixed both formats" case, so the old assertion isn't lost.

@yewmsft
Copy link
Copy Markdown
Member

yewmsft commented May 29, 2026

Related issues worth referencing

PR has no Fixes # link in the description. Found a few open issues that this PR partially or fully addresses — recommend linking so they auto-close or get tracked:

If the team is tracking the work internally in ADO instead, please link the ADO item in the PR description so reviewers can find the design context.

Pre-existing bug not introduced by this PR but worth flagging

The legacy path's error message in constructDefaultMaintenanceConfiguration:

"Please specify --weekday and --start-hour for default maintenance configuration, or use --config-file instead."

… is now wrong in this PR (it doesn't mention the new --schedule-type Weekly alternative). This PR updates it to include the new path — good. But that error has been the only feedback for users hitting this code path for years, and the error class is RequiredArgumentMissingError, which doesn't get a 'did you mean' hint. Not blocking, just noting that the help-text and error-text overlap is now the contract — keep them in sync in future changes.

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.

7 participants