From: Daniel Gomez <da.gomez@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>,
Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
kdevops@lists.linux.dev
Subject: Re: [PATCH v2 8/9] devconfig: add automatic APT mirror fallback for Debian testing
Date: Wed, 30 Jul 2025 08:41:12 +0200 [thread overview]
Message-ID: <0cc8da70-5146-4960-9e0a-6fe8b34eb05a@kernel.org> (raw)
In-Reply-To: <20250730060147.182140-9-mcgrof@kernel.org>
On 30/07/2025 08.01, Luis Chamberlain wrote:
> Debian testing (trixie) VMs can fail to provision when configured APT
> mirrors become unavailable or unresponsive. This is particularly common
> with local or regional mirrors that may have intermittent connectivity
> issues.
>
> This fix adds automatic mirror health checking specifically for Debian
> testing systems. The implementation:
>
> 1. Extracts the currently configured APT mirror hostname
> 2. Tests connectivity to the mirror on port 80 with a 10 second timeout
> 3. Falls back to official Debian mirrors if the test fails
> 4. Backs up the original sources.list before making changes
> 5. Updates the APT cache after switching mirrors
> 6. Provides clear user notification about the fallback
>
> The check only runs on Debian testing systems where devconfig_debian_testing
> is set to true, avoiding any impact on stable Debian or other distributions.
>
> This ensures that Debian testing VMs can successfully provision even when
> the initially configured mirror is unavailable, improving reliability for
> development and testing workflows.
>
> Generated-by: Claude AI
> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
> ---
> .../devconfig/tasks/check-apt-mirrors.yml | 63 +++++++++++++++++++
> playbooks/roles/devconfig/tasks/main.yml | 8 +++
> .../debian-testing-fallback-sources.list | 10 +++
> 3 files changed, 81 insertions(+)
> create mode 100644 playbooks/roles/devconfig/tasks/check-apt-mirrors.yml
> create mode 100644 playbooks/roles/devconfig/templates/debian-testing-fallback-sources.list
>
> diff --git a/playbooks/roles/devconfig/tasks/check-apt-mirrors.yml b/playbooks/roles/devconfig/tasks/check-apt-mirrors.yml
> new file mode 100644
> index 00000000..02e0c800
> --- /dev/null
> +++ b/playbooks/roles/devconfig/tasks/check-apt-mirrors.yml
> @@ -0,0 +1,63 @@
> +---
> +# Only run mirror checks for Debian testing (trixie) where mirror issues are common
> +- name: Extract current APT mirror hostname
> + shell: |
> + grep -E "^deb\s+http" /etc/apt/sources.list | head -1 | awk '{print $2}' | sed 's|http://||' | cut -d'/' -f1
> + register: apt_mirror_host
> + changed_when: false
> + ignore_errors: yes
> +
> +- name: Check connectivity to current APT mirror
> + wait_for:
> + host: "{{ apt_mirror_host.stdout }}"
> + port: 80
> + timeout: 10
> + register: mirror_connectivity
> + ignore_errors: yes
> + when: apt_mirror_host.stdout != ""
> +
> +- name: Display mirror check results
> + debug:
> + msg: |
> + Current APT mirror: {{ apt_mirror_host.stdout | default('Not found') }}
> + Mirror connectivity: {{ 'OK' if mirror_connectivity is not failed else 'FAILED' }}
> + when: apt_mirror_host.stdout != ""
> +
> +- name: Fall back to official Debian mirrors if current mirror fails
> + block:
> + - name: Backup current sources.list
> + copy:
> + src: /etc/apt/sources.list
> + dest: /etc/apt/sources.list.backup
> + remote_src: yes
> + become: yes
> +
> + - name: Apply Debian testing fallback sources
> + template:
> + src: debian-testing-fallback-sources.list
> + dest: /etc/apt/sources.list
> + owner: root
> + group: root
> + mode: '0644'
> + become: yes
> +
> + - name: Update APT cache after mirror change
> + apt:
> + update_cache: yes
> + cache_valid_time: 0
> + become: yes
> +
> + - name: Inform user about mirror fallback
> + debug:
> + msg: |
> + WARNING: The configured APT mirror '{{ apt_mirror_host.stdout }}' is not accessible.
> + Falling back to official Debian testing mirrors:
> + - deb.debian.org for main packages
> + - security.debian.org for security updates
> +
> + This may result in slower package downloads depending on your location.
> + Consider configuring a local mirror for better performance.
> +
> + when:
> + - apt_mirror_host.stdout != ""
> + - mirror_connectivity is failed
> diff --git a/playbooks/roles/devconfig/tasks/main.yml b/playbooks/roles/devconfig/tasks/main.yml
> index 656d5389..ceb0f2e8 100644
> --- a/playbooks/roles/devconfig/tasks/main.yml
> +++ b/playbooks/roles/devconfig/tasks/main.yml
> @@ -30,6 +30,14 @@
> tags: hostname
>
> # Distro specific
> +
> +# Check and fix APT mirrors for Debian testing before installing dependencies
> +- name: Check and fix APT mirrors for Debian testing
> + include_tasks: check-apt-mirrors.yml
> + when:
> + - devconfig_debian_testing is defined
> + - devconfig_debian_testing | bool
> +
> - name: Install dependencies
> ansible.builtin.include_tasks: install-deps/main.yml
> tags: ['vars', 'vars_simple']
> diff --git a/playbooks/roles/devconfig/templates/debian-testing-fallback-sources.list b/playbooks/roles/devconfig/templates/debian-testing-fallback-sources.list
> new file mode 100644
> index 00000000..456ed60f
> --- /dev/null
> +++ b/playbooks/roles/devconfig/templates/debian-testing-fallback-sources.list
> @@ -0,0 +1,10 @@
> +deb http://deb.debian.org/debian testing main contrib non-free non-free-firmware
> +deb-src http://deb.debian.org/debian testing main contrib non-free non-free-firmware
> +
> +# Security updates
> +deb http://security.debian.org/debian-security testing-security main contrib non-free non-free-firmware
> +deb-src http://security.debian.org/debian-security testing-security main contrib non-free non-free-firmware
> +
> +# Updates (if available for testing)
> +deb http://deb.debian.org/debian testing-updates main contrib non-free non-free-firmware
> +deb-src http://deb.debian.org/debian testing-updates main contrib non-free non-free-firmware
> \ No newline at end of file
Debian has switched to a new sources format [1]. They have also provided a
manual conversion for users with "apt modernize-sources". So it makes sense to
start using the new format directly here.
[1] https://wiki.debian.org/SourcesList
next prev parent reply other threads:[~2025-07-30 6:41 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 6:01 [PATCH v2 0/9] kdevops: add support for A/B testing Luis Chamberlain
2025-07-30 6:01 ` [PATCH v2 1/9] roles/guestfs: add missing bootlinux_9p: False Luis Chamberlain
2025-07-30 14:17 ` Chuck Lever
2025-07-30 6:01 ` [PATCH v2 2/9] Makefile: suppress Ansible warnings during configuration generation Luis Chamberlain
2025-07-30 6:22 ` Daniel Gomez
2025-07-30 6:01 ` [PATCH v2 3/9] playbooks: few space cleanups Luis Chamberlain
2025-07-30 6:01 ` [PATCH v2 4/9] style: add extensive code formatting checks to make style Luis Chamberlain
2025-07-30 6:01 ` [PATCH v2 5/9] Makefile: move styling to scripts/style.Makefile Luis Chamberlain
2025-07-30 6:01 ` [PATCH v2 6/9] CLAUDE.md: add instrucitons to verify commit Luis Chamberlain
2025-07-30 6:01 ` [PATCH v2 7/9] all: run black Luis Chamberlain
2025-07-31 12:57 ` Daniel Gomez
2025-08-01 8:12 ` Daniel Gomez
2025-08-01 12:55 ` Chuck Lever
2025-08-01 16:29 ` Daniel Gomez
2025-08-01 16:55 ` Chuck Lever
2025-07-30 6:01 ` [PATCH v2 8/9] devconfig: add automatic APT mirror fallback for Debian testing Luis Chamberlain
2025-07-30 6:41 ` Daniel Gomez [this message]
2025-08-01 17:39 ` Luis Chamberlain
2025-07-30 6:01 ` [PATCH v2 9/9] bootlinux: add support for A/B kernel testing Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0cc8da70-5146-4960-9e0a-6fe8b34eb05a@kernel.org \
--to=da.gomez@kernel.org \
--cc=cel@kernel.org \
--cc=da.gomez@kruces.com \
--cc=kdevops@lists.linux.dev \
--cc=mcgrof@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox