Proposal: Add Minimum and Maximum Retention Policies to Acr Purge
维护者通常 1 天内回复
评估
调研方向
从 acr purge 入口点开始,追踪现有的 --keep 行为、tag 和 dangling manifest 过滤、排序、分页以及 dry-run 报告。将验收标准作为完成定义:保持兼容性,验证 flag 组合,独立应用最小值/最大值策略,并覆盖分页、过滤器、已锁定项、相同时间戳以及新变为 dangling 的 manifest。
由索引模型根据 Issue 内容生成。
描述
What is the problem you're trying to solve
Customers need to combine age-based retention with minimum and maximum count limits.
For example, customers may want either of these behaviors:
- Delete tags older than 3 days or outside the 10 most recent matching tags.
- Delete tags older than 3 days only when they are outside the 10 most recent matching tags.
The existing --keep option does not express either policy consistently because it preserves items only from the set already eligible for age-based deletion. Changing its behavior would break existing purge configurations.
Describe the solution you'd like
Add explicit minimum and maximum retention options:
| Option | Behavior |
|---|---|
--min-tags N |
Protect the newest N matching tags from age-based deletion |
--max-tags N |
Retain no more than N matching tags per repository |
--min-untagged-manifests N |
Protect the newest N dangling manifests from age-based deletion |
--max-untagged-manifests N |
Retain no more than N dangling manifests per repository |
Maximum retention: OR behavior
acr purge \
--registry example \
--filter "repository:.*" \
--ago 3d \
--max-tags 10
A matching tag is deleted when it is older than 3 days or outside the 10 most recent matching tags. This is a hard ceiling; fewer than 10 tags may remain after applying the age policy.
Minimum retention: AND behavior
acr purge \
--registry example \
--filter "repository:.*" \
--ago 3d \
--min-tags 10
A matching tag is deleted only when it is older than 3 days and outside the 10 most recent matching tags. The newest 10 matching tags are protected from age-based deletion.
The same behavior applies independently to dangling manifests:
acr purge \
--registry example \
--untagged-only \
--ago 3d \
--min-untagged-manifests 20 \
--max-untagged-manifests 100
Combining minimum and maximum retention
Minimum and maximum options may be combined:
acr purge \
--registry example \
--filter "repository:.*" \
--ago 3d \
--min-tags 10 \
--max-tags 50
This creates three retention zones:
- The newest 10 matching tags are protected from age pruning.
- Tags 11 through 50 are retained only while newer than 3 days.
- Tags beyond 50 are deleted regardless of age.
Equivalent selection logic:
delete :=
rank > maxTags
OR
(olderThanAgo AND rank > minTags)
Compatibility and validation
- Existing
--keepbehavior remains unchanged. --keepcannot be combined with the new count policies for the same resource.--min-*requires--ago, because it guards age-based deletion and does not select items independently.--max-*works with or without--ago.- When both are supplied, the minimum must not exceed the maximum.
- Limits apply per repository and effective filter.
- Tag and dangling-manifest limits are independent.
- Items are ranked by
LastUpdateTime, newest first, with deterministic tie-breaking. - When using
--untagged, manifest retention is evaluated after tag deletion. - Locked items that prevent satisfying a maximum are reported clearly.
- Dry-run output identifies whether deletion is caused by age, maximum count, or both.
Repository-level conditions that determine whether purge runs at all, such as --purge-if-tags-exceed, are a separate feature and are not part of this retention proposal.
Acceptance criteria
- Age-only, minimum, maximum, and combined policies work for tags and dangling manifests.
- Minimum options provide AND behavior and maximum options provide OR behavior.
- Ranking works across paginated results.
- Existing filters and
--keepbehavior remain compatible. - Invalid flag combinations produce clear errors.
- Tests cover pagination, filters, locked items, equal timestamps, and manifests made dangling during the purge.
- 主要语言
- Go
- 星标
- 71
- 派生
- 52
- 平均合并
- 8 天 10 小时
- 30 天内合并 PR
- 4
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Azure/acr-cli 的其他 Issue
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
enhancement
难度 4/5 3-5 天 新手友好度 52/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 30/100
维护者通常 1 天内回复
相似的 Issue
-
proxy logs "no user in context" at error level for every data gateway download可能已有人在做 @paul43210 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 83/100
txn2/mcp-data-platform#2063 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
kubernetes-sigs/kueue#16990 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
enhancement exporter/awss3 needs triage
难度 2/5 1-3 小时 新手友好度 66/100
open-telemetry/opentelemetry-collector-contrib#51905 · 1 条评论 ·
维护者通常 1 天内回复