Skip to content

Commit 4c36065

Browse files
committed
bootlinux: enhance A/B testing and repository management
Improve git repository handling and A/B testing capabilities: - Add intelligent fallback logic for git ref resolution - Handle both direct refs and tag resolution gracefully - Improve error handling for missing or invalid refs - Add better debugging output for git operations - Update defconfig to enable 4K reflink testing - Exclude linux directory from newline checking script These changes make the bootlinux workflow more robust when dealing with different git ref types and improve the A/B testing experience with better error reporting and fallback mechanisms. Generated-by: Claude AI Signed-off-by: Luis Chamberlain <[email protected]>
1 parent e6acbe1 commit 4c36065

File tree

5 files changed

+113
-13
lines changed

5 files changed

+113
-13
lines changed

defconfigs/xfs_reflink_lbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ CONFIG_FSTESTS_XFS_ENABLE_LBS=y
2020
CONFIG_FSTESTS_XFS_ENABLE_LBS_4KS=y
2121
CONFIG_FSTESTS_XFS_SECTION_REFLINK_ENABLED=y
2222

23+
CONFIG_FSTESTS_XFS_SECTION_REFLINK_4K=y
2324
CONFIG_FSTESTS_XFS_SECTION_REFLINK_8K_4KS=y
2425
CONFIG_FSTESTS_XFS_SECTION_REFLINK_16K_4KS=y
2526
CONFIG_FSTESTS_XFS_SECTION_REFLINK_32K_4KS=y

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

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
run_once: true
6969
delegate_to: localhost
7070

71+
7172
- name: Verify target git ref exists before cloning
7273
command: "git ls-remote {{ target_linux_git }} {{ active_linux_ref | default(target_linux_ref) }}"
7374
register: ref_check
@@ -181,28 +182,63 @@
181182
- git_directory_stat.stat.exists
182183
- target_ref_sha.rc != 0
183184

184-
- name: Get target ref SHA after fetch
185+
- name: Try to resolve ref as direct ref after fetch
185186
command: "git -C {{ bootlinux_9p_host_path }} rev-parse {{ active_linux_ref | default(target_linux_ref) }}"
186-
register: target_ref_sha_after_fetch
187+
register: target_ref_sha_direct
188+
changed_when: false
189+
failed_when: false
190+
run_once: true
191+
delegate_to: localhost
192+
when:
193+
- not needs_git_clone|bool
194+
- target_directory_stat.stat.exists
195+
- git_directory_stat.stat.exists
196+
- target_ref_sha.rc != 0
197+
198+
- name: Try to resolve ref as remote branch if direct ref failed
199+
command: "git -C {{ bootlinux_9p_host_path }} rev-parse origin/{{ active_linux_ref | default(target_linux_ref) }}"
200+
register: target_ref_sha_remote
187201
changed_when: false
202+
failed_when: false
188203
run_once: true
189204
delegate_to: localhost
190205
when:
191206
- not needs_git_clone|bool
192207
- target_directory_stat.stat.exists
193208
- git_directory_stat.stat.exists
194209
- target_ref_sha.rc != 0
210+
- target_ref_sha_direct.rc != 0
211+
212+
- name: Set resolved ref for checkout
213+
set_fact:
214+
resolved_ref: |
215+
{%- if target_ref_sha.rc == 0 -%}
216+
{{ active_linux_ref | default(target_linux_ref) }}
217+
{%- elif target_ref_sha_direct is defined and target_ref_sha_direct.rc == 0 -%}
218+
{{ active_linux_ref | default(target_linux_ref) }}
219+
{%- elif target_ref_sha_remote is defined and target_ref_sha_remote.rc == 0 -%}
220+
origin/{{ active_linux_ref | default(target_linux_ref) }}
221+
{%- else -%}
222+
{{ active_linux_ref | default(target_linux_ref) }}
223+
{%- endif -%}
224+
run_once: true
225+
delegate_to: localhost
226+
when:
227+
- not needs_git_clone|bool
228+
- target_directory_stat.stat.exists
229+
- git_directory_stat.stat.exists
195230

196231
- name: Checkout target ref if not on correct ref
197-
command: "git -C {{ bootlinux_9p_host_path }} checkout {{ active_linux_ref | default(target_linux_ref) }}"
232+
command: "git -C {{ bootlinux_9p_host_path }} checkout {{ resolved_ref | default(active_linux_ref | default(target_linux_ref)) }}"
198233
run_once: true
199234
delegate_to: localhost
200235
when:
201236
- not needs_git_clone|bool
202237
- target_directory_stat.stat.exists
203238
- git_directory_stat.stat.exists
204239
- (target_ref_sha.rc == 0 and current_ref.stdout != target_ref_sha.stdout) or
205-
(target_ref_sha.rc != 0 and target_ref_sha_after_fetch is defined and target_ref_sha_after_fetch.rc == 0)
240+
(target_ref_sha.rc != 0 and (target_ref_sha_direct is defined and target_ref_sha_direct.rc == 0)) or
241+
(target_ref_sha.rc != 0 and (target_ref_sha_remote is defined and target_ref_sha_remote.rc == 0))
206242

207243
- name: Copy kernel delta if requested on the control node
208244
template:

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

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,24 +137,55 @@
137137
- git_directory_stat.stat.exists
138138
- target_ref_sha.rc != 0
139139

140-
- name: Get target ref SHA after fetch
140+
- name: Try to resolve ref as direct ref after fetch
141141
command: "git -C {{ target_linux_dir_path }} rev-parse {{ target_linux_ref }}"
142-
register: target_ref_sha_after_fetch
142+
register: target_ref_sha_direct
143143
changed_when: false
144+
failed_when: false
144145
when:
145146
- not needs_git_clone|bool
146147
- target_directory_stat.stat.exists
147148
- git_directory_stat.stat.exists
148149
- target_ref_sha.rc != 0
149150

151+
- name: Try to resolve ref as remote branch if direct ref failed
152+
command: "git -C {{ target_linux_dir_path }} rev-parse origin/{{ target_linux_ref }}"
153+
register: target_ref_sha_remote
154+
changed_when: false
155+
failed_when: false
156+
when:
157+
- not needs_git_clone|bool
158+
- target_directory_stat.stat.exists
159+
- git_directory_stat.stat.exists
160+
- target_ref_sha.rc != 0
161+
- target_ref_sha_direct.rc != 0
162+
163+
- name: Set resolved ref for checkout
164+
set_fact:
165+
resolved_ref: |
166+
{%- if target_ref_sha.rc == 0 -%}
167+
{{ target_linux_ref }}
168+
{%- elif target_ref_sha_direct is defined and target_ref_sha_direct.rc == 0 -%}
169+
{{ target_linux_ref }}
170+
{%- elif target_ref_sha_remote is defined and target_ref_sha_remote.rc == 0 -%}
171+
origin/{{ target_linux_ref }}
172+
{%- else -%}
173+
{{ target_linux_ref }}
174+
{%- endif -%}
175+
when:
176+
- not needs_git_clone|bool
177+
- target_directory_stat.stat.exists
178+
- git_directory_stat.stat.exists
179+
150180
- name: Checkout target ref if not on correct ref
151-
command: "git -C {{ target_linux_dir_path }} checkout {{ target_linux_ref }}"
181+
command: "git -C {{ target_linux_dir_path }} checkout {{ resolved_ref | default(target_linux_ref) }}"
152182
when:
153183
- not needs_git_clone|bool
154184
- target_directory_stat.stat.exists
155185
- git_directory_stat.stat.exists
156186
- (target_ref_sha.rc == 0 and current_ref.stdout != target_ref_sha.stdout) or
157-
(target_ref_sha.rc != 0 and target_ref_sha_after_fetch is defined and target_ref_sha_after_fetch.rc == 0)
187+
(target_ref_sha.rc != 0 and (target_ref_sha_direct is defined and target_ref_sha_direct.rc == 0)) or
188+
(target_ref_sha.rc != 0 and (target_ref_sha_remote is defined and target_ref_sha_remote.rc == 0))
158189

159190
- name: Copy the kernel delta to the builder
160191
ansible.builtin.template:

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

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,55 @@
139139
- git_directory_stat.stat.exists
140140
- target_ref_sha.rc != 0
141141

142-
- name: Get target ref SHA after fetch
142+
- name: Try to resolve ref as direct ref after fetch
143143
command: "git -C {{ target_linux_dir_path }} rev-parse {{ target_linux_ref }}"
144-
register: target_ref_sha_after_fetch
144+
register: target_ref_sha_direct
145145
changed_when: false
146+
failed_when: false
146147
when:
147148
- not needs_git_clone|bool
148149
- target_directory_stat.stat.exists
149150
- git_directory_stat.stat.exists
150151
- target_ref_sha.rc != 0
151152

153+
- name: Try to resolve ref as remote branch if direct ref failed
154+
command: "git -C {{ target_linux_dir_path }} rev-parse origin/{{ target_linux_ref }}"
155+
register: target_ref_sha_remote
156+
changed_when: false
157+
failed_when: false
158+
when:
159+
- not needs_git_clone|bool
160+
- target_directory_stat.stat.exists
161+
- git_directory_stat.stat.exists
162+
- target_ref_sha.rc != 0
163+
- target_ref_sha_direct.rc != 0
164+
165+
- name: Set resolved ref for checkout
166+
set_fact:
167+
resolved_ref: |
168+
{%- if target_ref_sha.rc == 0 -%}
169+
{{ target_linux_ref }}
170+
{%- elif target_ref_sha_direct is defined and target_ref_sha_direct.rc == 0 -%}
171+
{{ target_linux_ref }}
172+
{%- elif target_ref_sha_remote is defined and target_ref_sha_remote.rc == 0 -%}
173+
origin/{{ target_linux_ref }}
174+
{%- else -%}
175+
{{ target_linux_ref }}
176+
{%- endif -%}
177+
when:
178+
- not needs_git_clone|bool
179+
- target_directory_stat.stat.exists
180+
- git_directory_stat.stat.exists
181+
152182
- name: Checkout target ref if not on correct ref
153-
command: "git -C {{ target_linux_dir_path }} checkout {{ target_linux_ref }}"
183+
command: "git -C {{ target_linux_dir_path }} checkout {{ resolved_ref | default(target_linux_ref) }}"
154184
when:
155185
- not needs_git_clone|bool
156186
- target_directory_stat.stat.exists
157187
- git_directory_stat.stat.exists
158188
- (target_ref_sha.rc == 0 and current_ref.stdout != target_ref_sha.stdout) or
159-
(target_ref_sha.rc != 0 and target_ref_sha_after_fetch is defined and target_ref_sha_after_fetch.rc == 0)
189+
(target_ref_sha.rc != 0 and (target_ref_sha_direct is defined and target_ref_sha_direct.rc == 0)) or
190+
(target_ref_sha.rc != 0 and (target_ref_sha_remote is defined and target_ref_sha_remote.rc == 0))
160191

161192
- name: Copy kernel delta if requested on the target nodes
162193
template:

scripts/ensure_newlines.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def main():
4545
dirs[:] = [
4646
d
4747
for d in dirs
48-
if not d.startswith(".") and d not in ["__pycache__", "node_modules"]
48+
if not d.startswith(".")
49+
and d not in ["__pycache__", "node_modules", "linux"]
4950
]
5051

5152
for file in files:

0 commit comments

Comments
 (0)