Skip to content

Commit 178e0fb

Browse files
committed
bootlinux: add git ref verification before cloning
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 <[email protected]>
1 parent 3c2f0c9 commit 178e0fb

File tree

3 files changed

+72
-0
lines changed

3 files changed

+72
-0
lines changed

playbooks/roles/bootlinux/tasks/build/9p.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,35 @@
4444
- bootlinux_tree_set_by_cli|bool
4545
- not target_directory_stat.stat.exists
4646

47+
- name: Verify target git ref exists before cloning
48+
command: "git ls-remote {{ target_linux_git }} {{ active_linux_ref | default(target_linux_ref) }}"
49+
register: ref_check
50+
run_once: true
51+
delegate_to: localhost
52+
when:
53+
- not bootlinux_tree_set_by_cli|bool
54+
tags: [ 'clone']
55+
56+
- name: Fail if git ref does not exist
57+
fail:
58+
msg: |
59+
Failed to verify git ref '{{ active_linux_ref | default(target_linux_ref) }}' exists in repository '{{ target_linux_git }}'.
60+
61+
This typically happens when:
62+
1. The ref (branch/tag/commit) doesn't exist in the repository
63+
2. You're using A/B testing with a shallow clone that doesn't contain the required ref
64+
3. The repository URL is incorrect or inaccessible
65+
66+
Please verify:
67+
- The ref '{{ active_linux_ref | default(target_linux_ref) }}' exists in the repository
68+
- If using A/B testing with different refs, ensure shallow cloning is disabled
69+
- The repository URL '{{ target_linux_git }}' is correct and accessible
70+
when:
71+
- not bootlinux_tree_set_by_cli|bool
72+
- ref_check.rc != 0
73+
run_once: true
74+
delegate_to: localhost
75+
4776
- name: git clone {{ target_linux_tree }} on the control node
4877
git:
4978
repo: "{{ target_linux_git }}"

playbooks/roles/bootlinux/tasks/build/builder.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@
1010
- target_linux_install_b4
1111
- ansible_os_family == "Debian"
1212

13+
- name: Verify target git ref exists before cloning
14+
command: "git ls-remote {{ target_linux_git }} {{ target_linux_ref }}"
15+
register: ref_check
16+
17+
- name: Fail if git ref does not exist
18+
fail:
19+
msg: |
20+
Failed to verify git ref '{{ target_linux_ref }}' exists in repository '{{ target_linux_git }}'.
21+
22+
This typically happens when:
23+
1. The ref (branch/tag/commit) doesn't exist in the repository
24+
2. You're using A/B testing with a shallow clone that doesn't contain the required ref
25+
3. The repository URL is incorrect or inaccessible
26+
27+
Please verify:
28+
- The ref '{{ target_linux_ref }}' exists in the repository
29+
- If using A/B testing with different refs, ensure shallow cloning is disabled
30+
- The repository URL '{{ target_linux_git }}' is correct and accessible
31+
when:
32+
- ref_check.rc != 0
33+
1334
- name: Clone {{ target_linux_tree }}
1435
ansible.builtin.git:
1536
repo: "{{ target_linux_git }}"

playbooks/roles/bootlinux/tasks/build/targets.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@
1010
- target_linux_install_b4
1111
- ansible_facts['os_family']|lower != 'debian'
1212

13+
- name: Verify target git ref exists before cloning
14+
command: "git ls-remote {{ target_linux_git }} {{ target_linux_ref }}"
15+
register: ref_check
16+
tags: [ 'clone']
17+
18+
- name: Fail if git ref does not exist
19+
fail:
20+
msg: |
21+
Failed to verify git ref '{{ target_linux_ref }}' exists in repository '{{ target_linux_git }}'.
22+
23+
This typically happens when:
24+
1. The ref (branch/tag/commit) doesn't exist in the repository
25+
2. You're using A/B testing with a shallow clone that doesn't contain the required ref
26+
3. The repository URL is incorrect or inaccessible
27+
28+
Please verify:
29+
- The ref '{{ target_linux_ref }}' exists in the repository
30+
- If using A/B testing with different refs, ensure shallow cloning is disabled
31+
- The repository URL '{{ target_linux_git }}' is correct and accessible
32+
when:
33+
- ref_check.rc != 0
34+
1335
- name: git clone {{ target_linux_tree }} on the target nodes
1436
git:
1537
repo: "{{ target_linux_git }}"

0 commit comments

Comments
 (0)