Fix VCS stamping error in containerized builds with Podman#9008
Fix VCS stamping error in containerized builds with Podman#9008kaovilai wants to merge 5 commits intovelero-io:mainfrom
Conversation
57e39cd to
a093670
Compare
1ead63b to
584259f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9008 +/- ##
=======================================
Coverage 59.81% 59.81%
=======================================
Files 375 375
Lines 41056 41056
=======================================
Hits 24557 24557
Misses 15010 15010
Partials 1489 1489 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@blackpiglet Please double-check if the ownership issue only impacts podman. We have resolved something similar in downstream, but why we are not seeing this in upstream? |
|
@kaovilai According to the -buildvcs
Whether to stamp binaries with version control information
("true", "false", or "auto"). By default ("auto"), version control
information is stamped into a binary if the main package, the main module
containing it, and the current directory are all in the same repository.
Use -buildvcs=false to always omit version control information, or
-buildvcs=true to error out if version control information is available but
cannot be included due to a missing tool or ambiguous directory structure. |
|
I just found out |
|
@reasonerjt |
584259f to
edeb093
Compare
This commit addresses issue velero-io#9004 by adding git safe.directory configuration to fix 'dubious ownership' errors that occur when using Podman as the container runtime for builds. The issue was caused by a directory ownership mismatch where the mounted repository directory (/github.com/vmware-tanzu/velero) is owned by root:root but the files inside are owned by the mapped user. This triggers Git's security feature and causes VCS stamping to fail with exit code 128. Changes: - Add .gitconfig file with safe.directory configuration for the mounted path - Mount .gitconfig as read-only volume in the shell target - This allows Git operations to work properly inside the container The fix is minimal, targeted, and maintains VCS stamping functionality while being compatible with both Docker and Podman container runtimes. Fixes velero-io#9004 Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Clarifies why this configuration is needed to fix the Git 'dubious ownership' issue that occurs in Podman container environments where the mount point directory has different ownership than the files inside it. Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Added comment explaining that this file is mounted as /root/.gitconfig by the 'shell' target in the Makefile to provide better context for how this configuration is used in the build process. Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Updated Makefile to use $HOME/.gitconfig instead of /root/.gitconfig for better flexibility and to avoid hardcoded paths. Also updated the comment in .gitconfig to reflect this change. Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Removed separate .gitconfig mount as the file is already accessible through the main repository mount at /github.com/vmware-tanzu/velero. Git automatically finds the configuration file in the working directory. This approach is simpler, more robust, and avoids any path issues. Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
b4e10bb to
d32f63a
Compare
Thank you for contributing to Velero!
Please add a summary of your change
This PR fixes VCS stamping errors that occur when using Podman as the container runtime for builds by adding git safe.directory configuration to bypass Git's "dubious ownership" security check.
Root Cause: The mounted repository directory (
/github.com/vmware-tanzu/velero) is owned byroot:rootbut files inside are owned by the mapped user, triggering Git's security feature and causing VCS stamping to fail with exit code 128.Solution:
.gitconfigfile with[safe] directory = /github.com/vmware-tanzu/velero.gitconfigas read-only volume in theshelltarget:-v "$(pwd)/.gitconfig:/root/.gitconfig:ro"Testing: Verified that
git status, VCS stamping, andmake build-linux-amd64all work correctly after the fix.Does your change fix a particular issue?
Fixes #9004
Please indicate you've done the following:
make new-changelog) or comment/kind changelog-not-requiredon this PR.site/content/docs/main.