Skip to content

[KT VM] Replace python3-wget with curl for VM image download - #88

Open
PlaidCat wants to merge 1 commit into
mainlinefrom
{jmaple}_fix_wget_py314
Open

PlaidCat wants to merge 1 commit into
mainlinefrom
{jmaple}_fix_wget_py314

Conversation

@PlaidCat

@PlaidCat PlaidCat commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

GitHub's ubuntu-latest migrated to Ubuntu 26 on 2026-10-19, where system python3 is 3.14. This broke the kernel-tools CVE remediation workflows (kt list-kernels etc.) with:

AttributeError: module 'urllib.request' has no attribute 'FancyURLopener'

Root cause: kt/ktlib/vm.py uses the python3-wget package, whose only release is 0.0.2-beta1 from January 2017. It subclasses urllib.request.FancyURLopener, which was removed in Python 3.14. The package is dead upstream, so there is no version to bump to — the usage must be replaced.

Example failing run: https://github.com/ctrliq/kernel-tools/actions/runs/39555672007/job/120116391062

Changes

  • kt/ktlib/vm.py: dropped import wget; _download_source_image() now uses LocalCommand.run(command=["curl", "-fL", ...]), matching the existing curl-via-LocalCommand pattern in kt/commands/content_release/impl.py
    • -f preserves wget's fail-on-HTTP-error behavior (no more writing a 404 page into the qcow2)
    • -L follows redirects (wget default)
  • pyproject.toml: removed python3-wget (transitively drops hurry.filesize, cli-exit-tools, lib-detect-testenv)

Verification

  • pip install -e .[dev] resolves cleanly with no python3-wget in the tree
  • pytest: 118 passed
  • Import chain that failed on the runner (from kt.kt import main) + kt --help: OK in a venv with no wget installed at all
  • ruff check + ruff format --check clean with the pre-commit-pinned ruff 0.15.19

Notes

  • kernel_install_dep.sh references the shell wget CLI binary installed inside test VMs — unrelated, untouched
  • Follow-up: kernel-tools pins this repo by SHA (pyproject.toml + src_tree_tools_ref in the CVE remediation workflows) and needs a pin bump once this merges

Coverage Report

Name Stmts Miss Branch BrPart Cover Missing
check_fips_changes.py 42 42 12 0 0% 8-67
check_kernel_commits.py 179 179 76 0 0% 3-371
ciq-cherry-pick.py 194 100 54 3 49% 48-50, 55-90, 130, 173, 179-180, 201-202, 224-225, 240-242, 262-271, 294-331, 335-434
ciq-tag.py 146 146 16 0 0% 3-378
ciq_tag.py 232 232 54 0 0% 1-464
jira_pr_check.py 180 180 80 0 0% 3-381
kt/ktlib/ciq_helpers.py 328 223 152 6 29% 31-51, 74-106, 126->129, 136->151, 169-171, 242-243, 247, 252, 277-314, 327-333, 346-347, 351-353, 359, 380-382, 390-395, 404-406, 415-420, 431-444, 455-479, 489-503, 561-627, 636-646, 650-659, 669-684, 696-713
kt/ktlib/command_runner.py 33 20 6 0 33% 16, 20-33, 37-61, 65-66
kt/ktlib/config.py 59 0 16 0 100%
kt/ktlib/jira.py 148 119 32 0 16% 19-27, 39-55, 58-61, 64-68, 71-74, 77-80, 83-88, 91-98, 101-121, 124-131, 134-138, 142-157, 161-164, 171-184, 187-190, 193-209, 212-219, 222-224
kt/ktlib/kernel_workspace.py 147 50 28 2 62% 24, 100, 141-143, 148-150, 153-159, 172-183, 194-204, 221-224, 228-263
kt/ktlib/kernels.py 96 13 20 1 86% 77-85, 139, 155-162
kt/ktlib/local.py 5 1 0 0 80% 12
kt/ktlib/repo.py 29 15 2 0 45% 30-31, 34-35, 43-55
kt/ktlib/ssh.py 12 5 2 0 50% 9-12, 16
kt/ktlib/util.py 17 0 0 0 100%
kt/ktlib/virt.py 80 39 10 0 46% 26, 34-37, 51-78, 82-88, 92-93, 97, 101, 105, 109, 119-127, 133-138, 142-147
kt/ktlib/vm.py 312 148 56 3 51% 126-143, 176-185, 193-204, 233-237, 252->263, 280->286, 291-301, 304-305, 318-322, 325, 328-344, 349-366, 369-376, 385-391, 436-447, 450-451, 454, 458-463, 475-488, 501-508, 517, 526-538, 541-548, 551-560, 563
release_config.py 2 2 0 0 0% 7-27
rolling-release-update.py 264 264 106 0 0% 1-412
run_interdiff.py 165 165 56 0 0% 3-244
update_lt_spec.py 211 211 46 0 0% 9-400
TOTAL 2881 2154 824 15 23%

python3-wget (last released 2017) subclasses urllib.request.FancyURLopener,
which was removed in Python 3.14. This breaks the whole kt import chain
(kt -> content_release -> vm) wherever python3-wget gets installed, e.g.
GitHub runners on the new Ubuntu 26 images where python3 is 3.14:

  AttributeError: module 'urllib.request' has no attribute 'FancyURLopener'

Use curl via LocalCommand.run instead, matching the existing pattern in
kt/commands/content_release/impl.py. -f fails on HTTP errors (wget raised
on those) and -L follows redirects (wget default).

Also drops the dead python3-wget dependency and its transitive deps
(hurry.filesize, cli-exit-tools, lib-detect-testenv).
Copilot AI balanced review requested due to automatic review settings October 22, 2026 22:30
@PlaidCat PlaidCat self-assigned this Oct 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Failed downloads can leave truncated images that subsequent setup attempts incorrectly reuse as valid cached images.

1 open issue
What changed in this PR

Replaces the obsolete Python wget dependency with curl for VM image downloads, addressing the Python 3.14 import failure affecting kernel-tools workflows.

Changes:

  • Uses LocalCommand.run() to invoke curl with HTTP-error handling and redirect support.
  • Removes the python3-wget import and package dependency.
File Description
pyproject.toml Removes the obsolete python3-wget dependency.
kt/​ktlib/​vm.py Switches VM image downloads from Python wget to curl.

Review effort: Balanced

Comment thread kt/ktlib/vm.py

logging.info(f"Downloading image from {self._get_vm_url()}")
wget.download(self._get_vm_url(), out=str(self.qcow2_source_path))
LocalCommand.run(command=["curl", "-fL", self._get_vm_url(), "-o", str(self.qcow2_source_path)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants