Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow non-current user to own the directory which is built by ko #1219

Conversation

SaschaSchwarze0
Copy link
Member

@SaschaSchwarze0 SaschaSchwarze0 commented Feb 25, 2023

Changes

Go is running some Git commands to determine version control information of the directory that it builds to attach them as metadata to the binary. This leads to BuildRun failures when the directory is not owned by the current user:

go version go1.19.6 linux/arm64
ko version 0.12.0
2023/02/25 11:42:10 Using base [registry.access.redhat.com/ubi9/ubi-minimal@sha256:085c5049f5bd0b3cb33c322306a528373f79dc6f1098ff8f5a5b28f2685c53f8](http://registry.access.redhat.com/ubi9/ubi-minimal@sha256:085c5049f5bd0b3cb33c322306a528373f79dc6f1098ff8f5a5b28f2685c53f8) for [github.com/shipwright-io/build/cmd/shipwright-build-controller](http://github.com/shipwright-io/build/cmd/shipwright-build-controller)
2023/02/25 11:42:10 Building [github.com/shipwright-io/build/cmd/shipwright-build-controller](http://github.com/shipwright-io/build/cmd/shipwright-build-controller) for linux/arm64
2023/02/25 11:42:11 Unexpected error running "go build": exit status 1
# cd /workspace/source; git status --porcelain
fatal: detected dubious ownership in repository at '/workspace/source'
To add an exception for this directory, call:

	git config --global --add [safe.directory](http://safe.directory/) /workspace/source
error obtaining VCS status: exit status 128
	Use -buildvcs=false to disable VCS stamping.

In Shipwright, it is more or less always the case that the user is not owning the directory. The reason is that /workspace/source is an emptyDir volume that root is owning.

The error already contains the solution that I am using = adding it as a safe directory.

Submitter Checklist

  • Includes tests if functionality changed/was added
  • Includes docs if changes are user-facing
  • Set a kind label on this PR
  • Release notes block has been filled in, or marked NONE

Release Notes

The ko sample build strategy now makes the source directory a Git safe directory so that Go builds can retrieve version control information

@SaschaSchwarze0 SaschaSchwarze0 added the kind/bug Categorizes issue or PR as related to a bug. label Feb 25, 2023
@openshift-ci openshift-ci bot added the release-note Label for when a PR has specified a release note label Feb 25, 2023
Copy link
Contributor

@qu1queee qu1queee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 27, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Feb 27, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qu1queee

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 27, 2023
@openshift-merge-robot openshift-merge-robot merged commit fb8dee7 into shipwright-io:main Feb 27, 2023
@SaschaSchwarze0 SaschaSchwarze0 added this to the release-v0.12.0 milestone Mar 6, 2023
@SaschaSchwarze0 SaschaSchwarze0 deleted the sascha-ko-tolerate-directory-owner-mismatch branch March 22, 2023 14:52
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Label for when a PR has specified a release note size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants