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 3425F2DCF63 for ; Mon, 11 Aug 2025 22:43:10 +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=1754952191; cv=none; b=TxCT1nE6YFaOkIHVQsytZvVQ9tPKX5TAVdtKSWKKQJMaawhTkKeYL9ZqDTliv/Z6t4syRW/ai03kP+7abFa0bZwFbU874FoQHpZXkVMHFUyCOXHGZEy9G2wkY0/U6Gm48nrpB7S6/I69Cu8tP209B+3S3V136UsLT+ZQoiP/t0M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754952191; c=relaxed/simple; bh=e/SXH8ZbjTqRi+I6sn3sbCijGbBamUt30iOLh6yK40E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T9zV5fn2akjOkts8toSFlhN3gGw41GE74e2vUsKKqoYnaVP62d7v4VqqkArTBgJ7l9xEWyBJBshei1ku4nbdgzAwD51H4wJ0NHvJ8j4NqNJL3wnPE0OIHvCLQQS2X4IflEq39ZoWfE1KyXkj/k/O43JVRC4DXv3LRLGCpaBfMPk= 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=FKOQEQBV; 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="FKOQEQBV" 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=7+jqpv0IEFCow+N64uHneF2v0Fiovd2on7GdgsaHxhg=; b=FKOQEQBVJMCIABArHRL0CDdeQa n+73sR2QpjEB43osAcpqUtEDP/IlXJYPdea0OivnmUeDKbpqshL+EOYcpn+PwHGHeZ+CVwSIYs+K6 v/DoX3UdWOhVaUSiEQHu5GyMDajrfPW9gLrTILsKXsYNS43D/5OgiT941z3mGYfXSNE7n1N0t50cE I2QsE+dqJGiIUxYMAXUZvOiussA//7Y1WJKs3CSamud6YkpC2VMBBcwKClxAJkc1djQgxd41xgVyn 5zYADHQcahFTGHEKrERhgjBGi1hFDdZT2D//m7QtAc1qIrNHc/xMQRqH80AKgtsMHBVdG4kmf6HYC 3vB4G5Lw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1ulbET-00000009J8M-3d5N; Mon, 11 Aug 2025 22:43:09 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [PATCH 4/8] bootlinux: add git dirty check before cloning Date: Mon, 11 Aug 2025 15:43:03 -0700 Message-ID: <20250811224307.2218478-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250811224307.2218478-1-mcgrof@kernel.org> References: <20250811224307.2218478-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 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 --- 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