feat(docker): check that Docker publishes the suite before writing the apt source #159

Open
opened 2026-11-15 12:33:00 +00:00 by Dragonish · 2 comments
Collaborator

What

Before the docker role writes its apt source, check that Docker publishes the suite it is about to point at, and let an operator hold a host on an earlier release. No change to the file format.

Why

install.yml writes docker.list on every run with the current OS release (ansible_distribution_release). After an OS upgrade, the next run points apt at a suite that Docker has not published yet (Docker lags the Debian and Ubuntu releases), and apt update then fails for every package on the host, not only Docker's. A check that the suite exists, and a way to stay on the previous release until it does, prevents that.

(An earlier version of this issue claimed that docker.list keeps a stale suite. That was wrong: the file is rewritten every run and follows the OS. See the comment below.)

Proposed change

  • Send a HEAD request to <docker_repo_base_url>/dists/<suite>/Release before writing the source (status 200 or 404, a few retries, check_mode: false). Skip the check when the base URL is not http(s), so a local mirror still works.
  • On 404 with an existing Docker source: keep it and print a note that names the override. On 404 with no source: fail with a message that names the override.
  • New variable docker_apt_suite (string, default empty, meaning the OS release) to hold a host on an earlier release.
  • argument_specs, README, a changelog fragment, and Molecule cases for the 404 paths using a local HTTP server.

Not in this issue

The deb822 migration and a key refresh. Both are separate topics and, if they come back, they come back as their own opt-in issues.

Questions for the maintainer

  • Is docker_apt_suite the right name?
  • Should the check be on by default? I think yes: it can only prevent a broken apt update.
  • With no existing source and a 404, is failing the behaviour you want?
## What Before the `docker` role writes its apt source, check that Docker publishes the suite it is about to point at, and let an operator hold a host on an earlier release. No change to the file format. ## Why `install.yml` writes `docker.list` on every run with the current OS release (`ansible_distribution_release`). After an OS upgrade, the next run points apt at a suite that Docker has not published yet (Docker lags the Debian and Ubuntu releases), and `apt update` then fails for every package on the host, not only Docker's. A check that the suite exists, and a way to stay on the previous release until it does, prevents that. (An earlier version of this issue claimed that `docker.list` keeps a stale suite. That was wrong: the file is rewritten every run and follows the OS. See the comment below.) ## Proposed change - Send a `HEAD` request to `<docker_repo_base_url>/dists/<suite>/Release` before writing the source (status 200 or 404, a few retries, `check_mode: false`). Skip the check when the base URL is not http(s), so a local mirror still works. - On 404 with an existing Docker source: keep it and print a note that names the override. On 404 with no source: fail with a message that names the override. - New variable `docker_apt_suite` (string, default empty, meaning the OS release) to hold a host on an earlier release. - `argument_specs`, README, a changelog fragment, and Molecule cases for the 404 paths using a local HTTP server. ## Not in this issue The deb822 migration and a key refresh. Both are separate topics and, if they come back, they come back as their own opt-in issues. ## Questions for the maintainer - Is `docker_apt_suite` the right name? - Should the check be on by default? I think yes: it can only prevent a broken `apt update`. - With no existing source and a 404, is failing the behaviour you want?
Dragonish added the Kind/Enhancement label 2026-11-15 12:33:00 +00:00
Defame1297 added the
Priority
Medium
3
Status
Needs Triage
labels 2026-11-15 12:46:28 +00:00
Owner

Triage notes on this proposal. Part of it is good, part of the premise doesn't match the code.

"Stale suites" is not what the role does today. roles/docker/tasks/install.yml writes docker.list with copy and content: using {{ ansible_distribution_release }}, so every run rewrites it to the current OS release. The file follows the OS; it does not keep an old suite. The real failure is your second bullet, the opposite one: after an OS upgrade, a re-run points apt at a suite Docker hasn't published yet, and apt update breaks for every package. Please correct the description.

Key refresh is true. get_url skips when the destination exists, so docker.asc is never refreshed.

What is worth doing

  1. The suite-published check (dists/<suite>/Release), plus a prefixed override variable to hold a host on an earlier release. It fixes the real failure and changes no file format.
  2. Key refresh, if there is a safe way to do it.

What I'm not convinced of. deb822 itself is cosmetic: signed-by= in the one-line form is already valid. If the format change drives the migration (backup, write, verify docker-ce, roll back), most of the risk is self-inflicted, and the rollback path is hard to cover in Molecule. If it goes ahead, make it opt-in first. It must not be the default, because it rewrites a file on every consumer host.

Suggested split: one issue/PR for the suite check and override, a separate one for the optional deb822 migration. Please say whether you agree.

Status: Priority/Medium, Kind/Enhancement. Not Ready for Agent until the split is settled.

Triage notes on this proposal. Part of it is good, part of the premise doesn't match the code. **"Stale suites" is not what the role does today.** `roles/docker/tasks/install.yml` writes `docker.list` with `copy` and `content:` using `{{ ansible_distribution_release }}`, so every run rewrites it to the current OS release. The file follows the OS; it does not keep an old suite. The real failure is your second bullet, the opposite one: after an OS upgrade, a re-run points apt at a suite Docker hasn't published yet, and `apt update` breaks for every package. Please correct the description. **Key refresh is true.** `get_url` skips when the destination exists, so `docker.asc` is never refreshed. **What is worth doing** 1. The suite-published check (`dists/<suite>/Release`), plus a prefixed override variable to hold a host on an earlier release. It fixes the real failure and changes no file format. 2. Key refresh, if there is a safe way to do it. **What I'm not convinced of.** deb822 itself is cosmetic: `signed-by=` in the one-line form is already valid. If the format change drives the migration (backup, write, verify `docker-ce`, roll back), most of the risk is self-inflicted, and the rollback path is hard to cover in Molecule. If it goes ahead, make it opt-in first. It must not be the default, because it rewrites a file on every consumer host. **Suggested split:** one issue/PR for the suite check and override, a separate one for the optional deb822 migration. Please say whether you agree. Status: Priority/Medium, Kind/Enhancement. Not `Ready for Agent` until the split is settled.
Claude added
Status
Need More Info
2
and removed
Status
Needs Triage
labels 2026-11-15 13:21:46 +00:00
Author
Collaborator

Thanks, you are right, and I want to be clear about what was wrong.

The premise. I wrote that docker.list keeps a stale suite. In this role it does not: install.yml writes it with copy and content: using {{ ansible_distribution_release }}, so every run rewrites it to the current OS release. I described the behaviour of hosts I set up by hand, not of this role. The failure that does exist is the opposite one, as you say: after an OS upgrade, the next run points apt at a suite Docker has not published yet, and apt update breaks for every package. Key refresh is also as you say: get_url skips when docker.asc exists.

Agreed split.

  1. This issue becomes the suite check and the override, with no change to the file format. The body is rewritten accordingly and the deb822 migration is removed from it.
  2. deb822 migration: out of this issue. If it ever comes back, it comes back as its own opt-in issue, never as a default. I will not file it unless you ask.
  3. Key refresh: also separate, and I will not bundle it here (fetching a key from the network on every converge is a trust decision that deserves its own discussion).

What the PR would do (no code until you mark this Ready for Agent):

  • Before writing docker.list, send a HEAD request to <docker_repo_base_url>/dists/<suite>/Release (200 or 404, a few retries, check_mode: false; skipped when the base URL is not http(s), so a local mirror works).
  • On 404 with an existing Docker source: keep it, print a note naming the override. On 404 with no source: fail with a message that names the override.
  • docker_apt_suite (string, default empty = the OS release) holds a host on an earlier release.
  • argument_specs, README, a changelog fragment, and Molecule cases for the 404 paths using a local HTTP server.

Questions for you: is docker_apt_suite the right name; should the check be on by default (I think yes, it only ever prevents a broken apt update); and is failing, when there is no existing source, the behaviour you want?

I am marking this ready for your input.

Assisted-by: Claude Code

Thanks, you are right, and I want to be clear about what was wrong. **The premise.** I wrote that `docker.list` keeps a stale suite. In this role it does not: `install.yml` writes it with `copy` and `content:` using `{{ ansible_distribution_release }}`, so every run rewrites it to the current OS release. I described the behaviour of hosts I set up by hand, not of this role. The failure that does exist is the opposite one, as you say: after an OS upgrade, the next run points apt at a suite Docker has not published yet, and `apt update` breaks for every package. Key refresh is also as you say: `get_url` skips when `docker.asc` exists. **Agreed split.** 1. **This issue becomes the suite check and the override**, with no change to the file format. The body is rewritten accordingly and the deb822 migration is removed from it. 2. **deb822 migration:** out of this issue. If it ever comes back, it comes back as its own opt-in issue, never as a default. I will not file it unless you ask. 3. **Key refresh:** also separate, and I will not bundle it here (fetching a key from the network on every converge is a trust decision that deserves its own discussion). **What the PR would do** (no code until you mark this `Ready for Agent`): - Before writing `docker.list`, send a `HEAD` request to `<docker_repo_base_url>/dists/<suite>/Release` (200 or 404, a few retries, `check_mode: false`; skipped when the base URL is not http(s), so a local mirror works). - On 404 with an existing Docker source: keep it, print a note naming the override. On 404 with no source: fail with a message that names the override. - `docker_apt_suite` (string, default empty = the OS release) holds a host on an earlier release. - `argument_specs`, README, a changelog fragment, and Molecule cases for the 404 paths using a local HTTP server. **Questions for you:** is `docker_apt_suite` the right name; should the check be on by default (I think yes, it only ever prevents a broken `apt update`); and is failing, when there is no existing source, the behaviour you want? I am marking this ready for your input. Assisted-by: Claude Code
Dragonish changed title from feat(docker): deb822 apt source with a suite check and a safe migration (proposal) to feat(docker): check that Docker publishes the suite before writing the apt source 2026-11-15 14:14:24 +00:00
Dragonish added
Status
Ready for Human
and removed
Status
Need More Info
2
labels 2026-11-15 14:14:26 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#159