Skip to content

Clean up and refactor contrib/update.py - #1255

Merged
berendt merged 4 commits into
mainfrom
update-py-cleanup-refactor
Jul 24, 2026
Merged

Clean up and refactor contrib/update.py#1255
berendt merged 4 commits into
mainfrom
update-py-cleanup-refactor

Conversation

@ideaship

Copy link
Copy Markdown
Contributor

What

Refactors contrib/update.py (the scheduled image-definition updater) in three commits:

  1. Remove the dead mirror path + fix --dry-run. update.py carried its own MinIO upload (mirror_image) that broke in the Oct 2025 object-store migration — the default bucket name osism/openstack-images contains a / and is rejected by the minio client — and duplicated what contrib/mirror.py already does. It only ran in the non---dry-run path, which CI never exercises, so it sat broken for months. Removed it; mirror.py remains the sole uploader. --dry-run now honestly means "compute but do not write the YAML" (previously it rewrote the file regardless), and the scheduled workflow drops the flag so it still opens update PRs.

  2. Add a golden characterization test covering all six upstream parsing variants (AlmaLinux plain, CentOS 7 / Stream BSD + dated-filename, Rocky BSD, Ubuntu/Debian directory-listing), so the refactor is provably behaviour-preserving.

  3. Refactor discovery into pluggable handlers. Replace the per-shortname if/elif checksum-parsing branches with MirrorDirHandler / DirListingHandler, selected by a distro → handler registry plus a shortname → config table. Adding a new major becomes a config line instead of a code branch. Adds explicit request timeouts.

Testing

  • tox -e test -- test/unit — golden + --dry-run write-contract tests pass; parity confirmed against live upstream.
  • flake8 / black clean.

Notes

No change to the values update.py produces — the golden test pins that. This is groundwork for adding current distro majors; follow-up branches build on it.

🤖 Generated with Claude Code

ideaship added 3 commits July 18, 2026 15:04
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Roger Luethi <luethi@osism.tech>
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Roger Luethi <luethi@osism.tech>
Assisted-by: Claude:claude-sonnet-4-6
Signed-off-by: Roger Luethi <luethi@osism.tech>
test/unit/test_update.py imports the updater as `contrib.update`, but
contrib/ had no __init__.py, so `mypy .` (as run in CI) discovered
contrib/update.py under two module names ("update" and "contrib.update")
and aborted: "Source file found twice under different module names".

Make contrib a package, matching openstack_image_manager, so the file
resolves to a single module name and mypy passes.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Roger Luethi <luethi@osism.tech>
@berendt berendt moved this from New to In progress in Human Board Jul 20, 2026
@ideaship
ideaship marked this pull request as ready for review July 21, 2026 14:04
@ideaship ideaship moved this from In progress to Ready for review in Human Board Jul 21, 2026
@ideaship
ideaship requested a review from berendt July 22, 2026 15:58
@ideaship ideaship moved this from Ready for review to In review in Human Board Jul 22, 2026
@berendt
berendt merged commit 4170bad into main Jul 24, 2026
2 checks passed
@berendt
berendt deleted the update-py-cleanup-refactor branch July 24, 2026 06:56
@github-project-automation github-project-automation Bot moved this from In review to Done in Human Board Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants