From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
kdevops@lists.linux.dev
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 3/8] bootlinux: add git ref verification before cloning
Date: Mon, 11 Aug 2025 15:43:02 -0700 [thread overview]
Message-ID: <20250811224307.2218478-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20250811224307.2218478-1-mcgrof@kernel.org>
Add preliminary verification tasks to check if the target git ref exists
before attempting to clone the Linux kernel repository. This prevents
confusing git clone failures and provides clear, actionable error messages
to users.
The verification is particularly important for A/B testing scenarios where:
- Different kernel refs may be used for baseline vs development builds
- Shallow clones might not contain all required refs
- Users may specify refs that don't exist in the repository
Each build method now verifies the ref availability:
- 9p.yml: Verifies active_linux_ref (or target_linux_ref fallback)
- targets.yml: Verifies target_linux_ref on target nodes
- builder.yml: Verifies target_linux_ref on builder nodes
The error messages guide users to:
1. Check if the ref actually exists in the repository
2. Disable shallow cloning when using A/B testing with different refs
3. Verify the repository URL is correct and accessible
This change improves the user experience by failing fast with helpful
diagnostics rather than letting git clone fail with cryptic errors.
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
playbooks/roles/bootlinux/tasks/build/9p.yml | 29 +++++++++++++++++++
.../roles/bootlinux/tasks/build/builder.yml | 21 ++++++++++++++
.../roles/bootlinux/tasks/build/targets.yml | 22 ++++++++++++++
3 files changed, 72 insertions(+)
diff --git a/playbooks/roles/bootlinux/tasks/build/9p.yml b/playbooks/roles/bootlinux/tasks/build/9p.yml
index 1951e50e..98cbcb3c 100644
--- a/playbooks/roles/bootlinux/tasks/build/9p.yml
+++ b/playbooks/roles/bootlinux/tasks/build/9p.yml
@@ -44,6 +44,35 @@
- bootlinux_tree_set_by_cli|bool
- not target_directory_stat.stat.exists
+- name: Verify target git ref exists before cloning
+ command: "git ls-remote {{ target_linux_git }} {{ active_linux_ref | default(target_linux_ref) }}"
+ register: ref_check
+ run_once: true
+ delegate_to: localhost
+ when:
+ - not bootlinux_tree_set_by_cli|bool
+ tags: [ 'clone']
+
+- name: Fail if git ref does not exist
+ fail:
+ msg: |
+ Failed to verify git ref '{{ active_linux_ref | default(target_linux_ref) }}' exists in repository '{{ target_linux_git }}'.
+
+ This typically happens when:
+ 1. The ref (branch/tag/commit) doesn't exist in the repository
+ 2. You're using A/B testing with a shallow clone that doesn't contain the required ref
+ 3. The repository URL is incorrect or inaccessible
+
+ Please verify:
+ - The ref '{{ active_linux_ref | default(target_linux_ref) }}' exists in the repository
+ - If using A/B testing with different refs, ensure shallow cloning is disabled
+ - The repository URL '{{ target_linux_git }}' is correct and accessible
+ when:
+ - not bootlinux_tree_set_by_cli|bool
+ - ref_check.rc != 0
+ run_once: true
+ delegate_to: localhost
+
- name: git clone {{ target_linux_tree }} on the control node
git:
repo: "{{ target_linux_git }}"
diff --git a/playbooks/roles/bootlinux/tasks/build/builder.yml b/playbooks/roles/bootlinux/tasks/build/builder.yml
index c4c4b950..73cc6694 100644
--- a/playbooks/roles/bootlinux/tasks/build/builder.yml
+++ b/playbooks/roles/bootlinux/tasks/build/builder.yml
@@ -10,6 +10,27 @@
- target_linux_install_b4
- ansible_os_family == "Debian"
+- name: Verify target git ref exists before cloning
+ command: "git ls-remote {{ target_linux_git }} {{ target_linux_ref }}"
+ register: ref_check
+
+- name: Fail if git ref does not exist
+ fail:
+ msg: |
+ Failed to verify git ref '{{ target_linux_ref }}' exists in repository '{{ target_linux_git }}'.
+
+ This typically happens when:
+ 1. The ref (branch/tag/commit) doesn't exist in the repository
+ 2. You're using A/B testing with a shallow clone that doesn't contain the required ref
+ 3. The repository URL is incorrect or inaccessible
+
+ Please verify:
+ - The ref '{{ target_linux_ref }}' exists in the repository
+ - If using A/B testing with different refs, ensure shallow cloning is disabled
+ - The repository URL '{{ target_linux_git }}' is correct and accessible
+ when:
+ - ref_check.rc != 0
+
- name: Clone {{ target_linux_tree }}
ansible.builtin.git:
repo: "{{ target_linux_git }}"
diff --git a/playbooks/roles/bootlinux/tasks/build/targets.yml b/playbooks/roles/bootlinux/tasks/build/targets.yml
index 36339876..81465cc6 100644
--- a/playbooks/roles/bootlinux/tasks/build/targets.yml
+++ b/playbooks/roles/bootlinux/tasks/build/targets.yml
@@ -10,6 +10,28 @@
- target_linux_install_b4
- ansible_facts['os_family']|lower != 'debian'
+- name: Verify target git ref exists before cloning
+ command: "git ls-remote {{ target_linux_git }} {{ target_linux_ref }}"
+ register: ref_check
+ tags: [ 'clone']
+
+- name: Fail if git ref does not exist
+ fail:
+ msg: |
+ Failed to verify git ref '{{ target_linux_ref }}' exists in repository '{{ target_linux_git }}'.
+
+ This typically happens when:
+ 1. The ref (branch/tag/commit) doesn't exist in the repository
+ 2. You're using A/B testing with a shallow clone that doesn't contain the required ref
+ 3. The repository URL is incorrect or inaccessible
+
+ Please verify:
+ - The ref '{{ target_linux_ref }}' exists in the repository
+ - If using A/B testing with different refs, ensure shallow cloning is disabled
+ - The repository URL '{{ target_linux_git }}' is correct and accessible
+ when:
+ - ref_check.rc != 0
+
- name: git clone {{ target_linux_tree }} on the target nodes
git:
repo: "{{ target_linux_git }}"
--
2.47.2
next prev parent reply other threads:[~2025-08-11 22:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 22:42 [PATCH 0/8] linux-ab enhancements + monitor support Luis Chamberlain
2025-08-11 22:43 ` [PATCH 1/8] bootlinux: use different kernel for A/B testing by default Luis Chamberlain
2025-08-11 22:43 ` [PATCH 2/8] bootlinux: add support for custom refs on dev kernels on the CLI Luis Chamberlain
2025-08-11 22:43 ` Luis Chamberlain [this message]
2025-08-11 22:43 ` [PATCH 4/8] bootlinux: add git dirty check before cloning Luis Chamberlain
2025-08-11 22:43 ` [PATCH 5/8] bootlinux: add intelligent git repository detection and management Luis Chamberlain
2025-08-11 22:43 ` [PATCH 6/8] bootlinux: enhance A/B testing and repository management Luis Chamberlain
2025-08-11 22:43 ` [PATCH 7/8] fstests: add make target for running tests on all hosts Luis Chamberlain
2025-08-11 22:43 ` [PATCH 8/8] monitoring: integrate monitoring collection into fstests workflow Luis Chamberlain
2025-08-11 22:46 ` Luis Chamberlain
2025-08-12 0:49 ` Luis Chamberlain
2025-08-14 0:59 ` 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=20250811224307.2218478-4-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=cel@kernel.org \
--cc=da.gomez@kruces.com \
--cc=kdevops@lists.linux.dev \
/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