Skip to content

[ACR] Warn before overwriting an existing cache rule - #33911

Closed
Mabel Egba (mabelegba) wants to merge 6 commits into
Azure:devfrom
mabelegba:mabelegba/warn-cache-rule-overwrite
Closed

[ACR] Warn before overwriting an existing cache rule#33911
Mabel Egba (mabelegba) wants to merge 6 commits into
Azure:devfrom
mabelegba:mabelegba/warn-cache-rule-overwrite

Conversation

@mabelegba

@mabelegba Mabel Egba (mabelegba) commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ️✔️ All clear

Breaking Changes Tests
️✔️ None ️✔️ 130/130

Related command
az acr cache create

Description
Adds a warning that creating a cacherule with an existing name will overwrite it.

Testing Guide

  • Verified creating a cache rule displays the warning and succeeds.
  • Added a mock unit test for the warning.

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change
[Component Name 2] az command b: Add some customer-facing feature


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

mabelegba added 2 commits August 17, 2026 15:45
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e82f65c8-d0e4-4013-8ba8-5f3e0e19f031
Copilot AI lite review requested due to automatic review settings August 17, 2026 21:19
@mabelegba
Mabel Egba (mabelegba) requested a review from a team as a code owner August 17, 2026 21:19
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Mabel Egba (@mabelegba),
Since the current milestone time is less than 7 days, this pr may not catch up with this release.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a user-facing warning to az acr cache create when a cache rule with the same name already exists, signaling that the operation will overwrite the existing rule.

Changes:

  • Added an existence check in acr_cache_create and logs a warning when the cache rule already exists.
  • Added a mock unit test validating that the warning is emitted when the pre-check finds an existing rule.

Reviewed changes

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

File Description
src/azure-cli/azure/cli/command_modules/acr/cache.py Adds a preflight get call and warning before overwriting an existing cache rule.
src/azure-cli/azure/cli/command_modules/acr/tests/latest/test_acr_commands_mock.py Adds a mock test to assert the overwrite warning is logged.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/azure-cli/azure/cli/command_modules/acr/cache.py Outdated
@northtyphoon

Copy link
Copy Markdown
Member

what do we allow implicit overwrite in az acr cache command? it already provides update, delete/create commands.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e82f65c8-d0e4-4013-8ba8-5f3e0e19f031
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@mabelegba

Copy link
Copy Markdown
Contributor Author

what do we allow implicit overwrite in az acr cache command? it already provides update, delete/create commands.

Bin Du (@northtyphoon)
This behavior already exists because az acr cache create behaves like an upsert operation. If a cache rule is created with a specific cache-rule name that doesn't exist yet, it creates it but if the cache rule already exists, it overwrites it and this PR only provides visible warning.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: e82f65c8-d0e4-4013-8ba8-5f3e0e19f031
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

source_repo='mcr.microsoft.com/mcr/hello-world',
target_repo='hello-world')

mock_warning.assert_called_once_with(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Are we testing both outcomes, ie. if the rule already exists and if it doesn't exist? How does the test guarantee that the rule exists?

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants