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 4/8] bootlinux: add git dirty check before cloning
Date: Mon, 11 Aug 2025 15:43:03 -0700 [thread overview]
Message-ID: <20250811224307.2218478-5-mcgrof@kernel.org> (raw)
In-Reply-To: <20250811224307.2218478-1-mcgrof@kernel.org>
Add preliminary checks to detect if the git tree has local modifications
before attempting to clone or update. This provides clearer error messages
when git operations fail due to uncommitted changes.
The issue was discovered when prior kdevops commits inadvertently modified
files in the linux kernel tree through overly broad make style operations.
When git clone/update encounters a dirty tree, it fails with a generic
"Local modifications exist" error that doesn't guide users on resolution.
Each build method now checks for dirty trees:
- 9p.yml: Checks bootlinux_9p_host_path on control node
- targets.yml: Checks target_linux_dir_path on target nodes
- builder.yml: Checks target_linux_dir_path on builder nodes
The error messages provide clear resolution steps:
1. Commit or stash changes
2. Hard reset the tree
3. Remove the directory for a fresh clone
This change improves debugging by:
- Failing fast with actionable error messages
- Showing which files are modified
- Providing multiple resolution options
- Preventing confusing git errors downstream
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
playbooks/roles/bootlinux/tasks/build/9p.yml | 43 +++++++++++++++++++
.../roles/bootlinux/tasks/build/builder.yml | 33 ++++++++++++++
.../roles/bootlinux/tasks/build/targets.yml | 33 ++++++++++++++
3 files changed, 109 insertions(+)
diff --git a/playbooks/roles/bootlinux/tasks/build/9p.yml b/playbooks/roles/bootlinux/tasks/build/9p.yml
index 98cbcb3c..5c9489c3 100644
--- a/playbooks/roles/bootlinux/tasks/build/9p.yml
+++ b/playbooks/roles/bootlinux/tasks/build/9p.yml
@@ -73,6 +73,49 @@
run_once: true
delegate_to: localhost
+- name: Check if target directory exists for dirty check
+ stat:
+ path: "{{ bootlinux_9p_host_path }}"
+ register: git_dir_stat
+ run_once: true
+ delegate_to: localhost
+ when:
+ - not bootlinux_tree_set_by_cli|bool
+
+- name: Check if git tree is dirty
+ command: "git -C {{ bootlinux_9p_host_path }} status --porcelain"
+ register: git_status
+ changed_when: false
+ failed_when: false
+ run_once: true
+ delegate_to: localhost
+ when:
+ - not bootlinux_tree_set_by_cli|bool
+ - git_dir_stat.stat.exists
+ - git_dir_stat.stat.isdir
+
+- name: Fail if git tree has local modifications
+ fail:
+ msg: |
+ Local modifications exist in the destination: {{ bootlinux_9p_host_path }}
+
+ The git tree is dirty with uncommitted changes. This prevents safe git operations.
+
+ To resolve this, you can:
+ 1. Commit or stash your changes in {{ bootlinux_9p_host_path }}
+ 2. Reset the tree with: git -C {{ bootlinux_9p_host_path }} reset --hard
+ 3. Remove the directory and let kdevops clone fresh: rm -rf {{ bootlinux_9p_host_path }}
+
+ Modified files:
+ {{ git_status.stdout }}
+ when:
+ - not bootlinux_tree_set_by_cli|bool
+ - git_dir_stat.stat.exists
+ - git_dir_stat.stat.isdir
+ - git_status.stdout | length > 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 73cc6694..d36815ed 100644
--- a/playbooks/roles/bootlinux/tasks/build/builder.yml
+++ b/playbooks/roles/bootlinux/tasks/build/builder.yml
@@ -31,6 +31,39 @@
when:
- ref_check.rc != 0
+- name: Check if target directory exists for dirty check
+ stat:
+ path: "{{ target_linux_dir_path }}"
+ register: git_dir_stat
+
+- name: Check if git tree is dirty
+ command: "git -C {{ target_linux_dir_path }} status --porcelain"
+ register: git_status
+ changed_when: false
+ failed_when: false
+ when:
+ - git_dir_stat.stat.exists
+ - git_dir_stat.stat.isdir
+
+- name: Fail if git tree has local modifications
+ fail:
+ msg: |
+ Local modifications exist in the destination: {{ target_linux_dir_path }}
+
+ The git tree is dirty with uncommitted changes. This prevents safe git operations.
+
+ To resolve this, you can:
+ 1. Commit or stash your changes in {{ target_linux_dir_path }}
+ 2. Reset the tree with: git -C {{ target_linux_dir_path }} reset --hard
+ 3. Remove the directory and let kdevops clone fresh: rm -rf {{ target_linux_dir_path }}
+
+ Modified files:
+ {{ git_status.stdout }}
+ when:
+ - git_dir_stat.stat.exists
+ - git_dir_stat.stat.isdir
+ - git_status.stdout | length > 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 81465cc6..414602ab 100644
--- a/playbooks/roles/bootlinux/tasks/build/targets.yml
+++ b/playbooks/roles/bootlinux/tasks/build/targets.yml
@@ -32,6 +32,39 @@
when:
- ref_check.rc != 0
+- name: Check if target directory exists for dirty check
+ stat:
+ path: "{{ target_linux_dir_path }}"
+ register: git_dir_stat
+
+- name: Check if git tree is dirty
+ command: "git -C {{ target_linux_dir_path }} status --porcelain"
+ register: git_status
+ changed_when: false
+ failed_when: false
+ when:
+ - git_dir_stat.stat.exists
+ - git_dir_stat.stat.isdir
+
+- name: Fail if git tree has local modifications
+ fail:
+ msg: |
+ Local modifications exist in the destination: {{ target_linux_dir_path }}
+
+ The git tree is dirty with uncommitted changes. This prevents safe git operations.
+
+ To resolve this, you can:
+ 1. Commit or stash your changes in {{ target_linux_dir_path }}
+ 2. Reset the tree with: git -C {{ target_linux_dir_path }} reset --hard
+ 3. Remove the directory and let kdevops clone fresh: rm -rf {{ target_linux_dir_path }}
+
+ Modified files:
+ {{ git_status.stdout }}
+ when:
+ - git_dir_stat.stat.exists
+ - git_dir_stat.stat.isdir
+ - git_status.stdout | length > 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 ` [PATCH 3/8] bootlinux: add git ref verification before cloning Luis Chamberlain
2025-08-11 22:43 ` Luis Chamberlain [this message]
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-5-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