From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B1FE1E1DE5 for ; Wed, 30 Jul 2025 06:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753855313; cv=none; b=VmKXMtdQmTXo2amcRHW8wBdzo+CfIFTHvSLeBU0D7vwrAfCdHUBaiEN5SyxBIYCm0++LucvCxwSNvOt0uly7bsZngG0p+rt1+gAQjjABMj9/Yy3tW3A4rSCz5AgNhpdLsEZNKAdKQEtch4u31c20NMv+A/jI0GB8c4e1iHOebiE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753855313; c=relaxed/simple; bh=nidhJWVucUCLLRBn9eKnapcUCqD3wt7zIsz8W/Kpo9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hzgnFlxc31mGSs97NGg1uG8wzfWokyt7+J83ny6u0e8qbsZ5nPhRjpI/rVzRHxNMToL+wtqwYKyPdC6KbBWTnFVPbNR5QLW4xmrY6NY5EaisI8dGHpsTuvRZx1zY/p83vKfwlcX0fzDE4fp0f5RcQ89GW5ITSzyHH/96Ga8/2q4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=kfDbit0y; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="kfDbit0y" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=C+ZPYU5tVZisiDzHeCHzXGmzs7Y6LzKwBOt63pj2+ho=; b=kfDbit0yQEZgm7A3qOGY/O1oGN +ZqnJveTjQ8toTARk6xjAYmtDwkbbdxj6wH1IFsLFbiZhf18I9SoqOp3CWGMbHknzJtObC75w1gYP aq//5J9GaLPdHu6ECOCUeI708TKarhHepJsNieHAgkOokdmGZUGVA6j9pStmw1xwNAGv21JRRto4q 5H9GyRSAB+DM5WOR6wjyEtVrzD3o9+7cLnKS3g3HI+PzUUkDtWzVnhzYgJ/g7L7omJ8e6xJ6NQPOQ bktPGGhgUMXDFsT1/GCOxRpZ5S59nDMG5PDpIQ90ih07s6un/6/DSlMv//8IAy0fn8RDpbVgHfZgj s7ZZJiRw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1ugzst-00000000lOt-0dUk; Wed, 30 Jul 2025 06:01:51 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH v2 8/9] devconfig: add automatic APT mirror fallback for Debian testing Date: Tue, 29 Jul 2025 23:01:44 -0700 Message-ID: <20250730060147.182140-9-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250730060147.182140-1-mcgrof@kernel.org> References: <20250730060147.182140-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain 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 --- .../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 -- 2.47.2