Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

image prune: --filter until= with an empty value is ignored and prunes every unused image

未关闭
#5,303 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@ogulcanaydogan 已经在做这个了。

开始于 2026年10月28日。

  • #5304 来自 @ogulcanaydogan —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
go
领域
cli, testing

调研方向

Start with pkg/imgutil/filtering.go and the reported ParseFilters check, then read TestFilterUntil and the parsing tests. The issue reports an open linked pull request (#5304), so work is already underway. Done means ParseFilters([]string{"until="}) returns the expected “no until timestamp provided” error.

由索引模型根据 Issue 内容生成。

描述

Description

imgutil.ParseFilters accepts until= with an empty value, and nerdctl image prune then ignores the filter and prunes every image it would prune without a filter.

In pkg/imgutil/filtering.go the check for an empty timestamp looks at the filter name instead of the value, so it can never fail:

} else if tempFilterToken[0] == FilterUntilType {
	if len(tempFilterToken[0]) == 0 {   // tempFilterToken[0] is "until"
		return nil, errNoUntilTimestamp

f.Until stays empty, and pkg/cmd/image/prune.go only adds the until filter when len(parsedFilters.Until) > 0. So nerdctl image prune -a --filter until= removes all unused images (and without -a all dangling images) instead of returning no until timestamp provided, which is what FilterUntil("") and the existing TestFilterUntil expect. It also matters in scripts that build the value, for example --filter until=$(some-command) where the command prints nothing, together with --force.

I found this by reading the code and checked it with a unit test on ParseFilters, not by running nerdctl image prune against containerd.

Steps to reproduce the issue
_, err := imgutil.ParseFilters([]string{"until="})
// err is nil, errNoUntilTimestamp is expected

Or nerdctl image prune -a --force --filter until= on a host with unused images.

Describe the results you received and expected

Received: no error, and the unused images are removed as if no filter was given.
Expected: no until timestamp provided, and nothing is removed.

What version of nerdctl are you using?

main (5140812f)

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

No

Host information

macOS, go1.26.8 (the unit test does not need containerd)

主要语言
Go
星标
10.5k
派生
839
平均合并
3 天 22 小时
30 天内合并 PR
38

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

containerd/nerdctl 的其他 Issue

查看 containerd/nerdctl 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。