docker-to-squash.py does not run on Python 3

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

维护者通常 1 天内回复

@ToniAdreal 已经在做这个了。

开始于 2026年11月22日。

  • #9296 来自 @ToniAdreal —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
54/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker, python
领域
tooling

调研方向

Start with bin/docker-to-squash.py, especially the named functions and argument declarations: calculate_string_hash, read_image_tag_to_hash, write_local_image_tag_to_hash, convert_oci_whiteouts, and get_all_known_images. Run the reported python3 bin/docker-to-squash.py --help reproduction, then exercise the listed subcommands to check Python 3 behavior. Done means argument parsing and the affected commands work on Python 3, including byte handling and tag mapping.

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

描述

bin/docker-to-squash.py still uses Python 2 APIs and treats subprocess output (bytes) as str, so on Python 3 no subcommand gets past argument parsing.

Storm 3.3.0-SNAPSHOT (master 4fca209). Reproduced with Python 3.9, 3.10, and 3.13.

$ python3 bin/docker-to-squash.py --help
ImportError: cannot import name 'Iterable' from 'collections'

That comes from from collections import Iterable, which was removed in Python 3.10. On Python 3.9 the import succeeds, but --untagged-transition-sec is declared with type=long, and building the parser raises NameError: name 'long' is not defined.

Expected: the script imports, parses arguments, and runs subcommands on Python 3.

Actual: it fails as above before any subcommand runs. With those two patched, later calls still fail:

  • calculate_string_hash passes str(out) to sha.update and raises TypeError: Strings must be encoded before hashing. pull-build, pull-build-push-update, push-update, and add-tag hit this, and so do query-tag and copy-update when they find the tag.
  • write_local_image_tag_to_hash uses hash_to_tags.iteritems(), so commands that write the tag mapping (for example remove-tag) raise AttributeError.
  • get_all_known_images calls bytes.split(...), so remove-image and cleanup raise TypeError. Those functions also call long() later on.
  • read_image_tag_to_hash does str(line) on bytes, so t1:<hash>\n becomes b't1:<hash>\n'. Lines without a #comment fail the sha256 check and are dropped; lines with one keep a b' prefix on the first tag. query-tag and copy-update then miss the existing tag.
  • convert_oci_whiteouts does str(out).splitlines(), which joins the paths into one string, so no whiteout is converted. The failed commands are also hidden by the shell_command issue.

Once Iterable and long are patched, list-tags and bootstrap run to completion.

Follow-up from the review discussion in #9284 ʕ•ᴥ•ʔ

主要语言
Java
星标
6.7k
派生
4k
平均合并
1 天 5 小时
30 天内合并 PR
86

环境准备

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

从这里开始

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

apache/storm 的其他 Issue

查看 apache/storm 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

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