fix(images): name the registry client and report a refused request #341

Merged
Defame1297 merged 1 commits from fix/next-image-version-user-agent into main 2026-11-23 22:16:13 +00:00
Owner

What and why

Refs #165 (follow-up to #340)

The first Images run after #340 (run 5229) failed before building anything. The first registry request from scripts/next_image_version.py (GET /v2/mortis/molecule-ubuntu2404/tags/list) got HTTP 403 and ended in a bare traceback. Nothing was pushed and no tag moved.

The same request works from a developer machine, and curl in the same job reaches the same host. The suspected cause is a bot filter refusing Python's default Python-urllib User-Agent. This is not confirmed: the old script did not print the response body.

Changes to scripts/next_image_version.py:

  • User-Agent: every registry request, the token request included, sends User-Agent: kamino-next-image-version.
  • Readable errors: every HTTP error becomes a RegistryError naming the status and the visible text of the response body. Script and style blocks and tags are stripped, and the text is cut to 300 characters. main prints it as one ::error:: line and exits 1. A block page is then recognisable in the job log.
  • One login at most: a 401 after the login is final, so an empty token cannot loop.
  • Registry URL argument: the CLI takes the registry URL instead of the host, so the tests can drive it against a local fake registry. image.yml now passes $SERVER_URL.

No changelog fragment: this is CI-internal.

Verified

  • python3 -m unittest discover -s tests/scripts: 227 tests pass, repeated 3 times.
    • New tests run against a local fake registry (http.server) and cover:
      • every request sending the client's User-Agent;
      • a 403 block page with a large <style> block (status and text);
      • a refused token (401 with body);
      • a 401 without a realm;
      • one login only with an empty token;
      • the CLI printing one ::error:: line and exiting 1 with empty stdout.
    • Each new test was seen failing first, except the missing-realm test, which covers a branch that already existed.
  • pre-commit run --all-files and ansible-test sanity (pylint) pass.
  • A live read-only run of the client against the registry from a developer machine still reads tags and labels.
  • Subagent review ran to clean: four rounds (standards and spec, then combined), with every finding fixed until the last round reported none. A reviewer confirmed that the empty-token test fails without its fix.

Not verified

  • Whether the User-Agent is the cause of the 403. If it is not, the next run still fails, but the log now shows the status and the page text. The fallback is to read the tags with curl, which already reaches the host from the runner.
  • The Images run itself. After the merge I'll start Images by manual dispatch from main and watch it through the version step, the push, the Renovate workflow_run and the pin PR.
  • The rest of #340's not-verified list still stands: the pristine-filesystem check with python3, kaniko writing the label, and Renovate starting after Images.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code:claude-opus-5-5

## What and why Refs #165 (follow-up to #340) The first Images run after #340 ([run 5229](https://git.rkdr.net/Mortis/Kamino/actions/runs/5229)) failed before building anything. The first registry request from `scripts/next_image_version.py` (`GET /v2/mortis/molecule-ubuntu2404/tags/list`) got **HTTP 403** and ended in a bare traceback. Nothing was pushed and no tag moved. The same request works from a developer machine, and `curl` in the same job reaches the same host. The suspected cause is a bot filter refusing Python's default `Python-urllib` User-Agent. **This is not confirmed:** the old script did not print the response body. Changes to `scripts/next_image_version.py`: - **User-Agent:** every registry request, the token request included, sends `User-Agent: kamino-next-image-version`. - **Readable errors:** every HTTP error becomes a `RegistryError` naming the status and the visible text of the response body. Script and style blocks and tags are stripped, and the text is cut to 300 characters. `main` prints it as one `::error::` line and exits 1. A block page is then recognisable in the job log. - **One login at most:** a 401 after the login is final, so an empty token cannot loop. - **Registry URL argument:** the CLI takes the registry URL instead of the host, so the tests can drive it against a local fake registry. `image.yml` now passes `$SERVER_URL`. No changelog fragment: this is CI-internal. ## Verified - `python3 -m unittest discover -s tests/scripts`: 227 tests pass, repeated 3 times. - New tests run against a local fake registry (`http.server`) and cover: - every request sending the client's User-Agent; - a 403 block page with a large `<style>` block (status and text); - a refused token (401 with body); - a 401 without a realm; - one login only with an empty token; - the CLI printing one `::error::` line and exiting 1 with empty stdout. - Each new test was seen failing first, except the missing-realm test, which covers a branch that already existed. - `pre-commit run --all-files` and `ansible-test sanity` (pylint) pass. - A live read-only run of the client against the registry from a developer machine still reads tags and labels. - Subagent review ran to clean: four rounds (standards and spec, then combined), with every finding fixed until the last round reported none. A reviewer confirmed that the empty-token test fails without its fix. ## Not verified - **Whether the User-Agent is the cause of the 403.** If it is not, the next run still fails, but the log now shows the status and the page text. The fallback is to read the tags with `curl`, which already reaches the host from the runner. - The Images run itself. After the merge I'll start Images by manual dispatch from `main` and watch it through the version step, the push, the Renovate `workflow_run` and the pin PR. - The rest of #340's not-verified list still stands: the pristine-filesystem check with `python3`, kaniko writing the label, and Renovate starting after Images. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code:claude-opus-5-5
Claude added this to the CI velocity (emergency) milestone 2026-11-23 22:13:52 +00:00
Defame1297 was assigned by Claude 2026-11-23 22:13:52 +00:00
Claude added 1 commit 2026-11-23 22:13:52 +00:00
fix(images): name the registry client and report a refused request
Build / build (pull_request) Successful in 15s
Lint / lint (pull_request) Successful in 59s
Molecule / molecule (pull_request) Successful in 2s
30316c5a7d
The first Images run after #165 failed: the runner's first registry request
from next_image_version.py got HTTP 403, as a bare traceback, while the same
request works from elsewhere and curl reaches the host in the same job. The
suspected cause, a bot filter refusing Python's default User-Agent, is not
confirmed.

Every registry request, the token request included, now sends its own
User-Agent. Every HTTP error becomes a RegistryError that names the status and
the visible text of the response body, and main prints it as one ::error::
line and exits 1. The client logs in at most once, so an empty token cannot
loop. The script takes the registry URL, so the tests drive it against a local
fake registry.

Refs #165

Assisted-by: Claude Code:claude-opus-5-5
CODEOWNERS rules requested review from Defame1297 2026-11-23 22:13:52 +00:00
Defame1297 scheduled this pull request to auto merge when all checks succeed 2026-11-23 22:15:04 +00:00
Defame1297 approved these changes 2026-11-23 22:16:13 +00:00
Defame1297 merged commit 85d26de084 into main 2026-11-23 22:16:13 +00:00
Defame1297 deleted branch fix/next-image-version-user-agent 2026-11-23 22:16:13 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#341