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

Fixing golangci-lint cache permission issue #565

Conversation

LalatenduMohanty
Copy link
Member

@LalatenduMohanty LalatenduMohanty commented Sep 26, 2019

It seems like an issue when go code running in container as non-root user, and the user does not exist in the container. Go by default disables the cache. It seems we will need to set GOCACHE explicitly when running a build as a nonexistent user (in our case it is root I think) [1] . Not sure what user ID we are expected to use in the CI system.

As per [2] $XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

The idea is to set it to a location where the go program (in this case golangci-lint) have write access.

[1] golang/go#26280
[2] https://specifications.freedesktop.org/basedir-spec/0.6/ar01s03.html

Signed-off-by: Lalatendu Mohanty lmohanty@redhat.com

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 26, 2019
@LalatenduMohanty
Copy link
Member Author

/hold
Will do few reruns to make sure it works

@openshift-ci-robot openshift-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 26, 2019
@dgoodwin
Copy link
Contributor

Could you clarify what this env var is and why it fixes the problem in commit message.

@LalatenduMohanty
Copy link
Member Author

LalatenduMohanty commented Sep 27, 2019

Could you clarify what this env var is and why it fixes the problem in commit messag

Will do.
It seems like an issue when go code running in container as non-root user, and the user does not exist in the container. Go by default disables the cache. It seems we will need to set GOCACHE explicitly when running a build as a nonexistent user (in our case it is root I think) [1] . Not sure what user ID we are expected to use in the CI system.

As per [2] $XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

The idea is to set it to a location where the go program (in this case golangci-lint) have write access.

[1] golang/go#26280
[2] https://specifications.freedesktop.org/basedir-spec/0.6/ar01s03.html

@LalatenduMohanty
Copy link
Member Author

/test unit

As go disables the cache if go code does got expected user previlages
to run. $XDG_CACHE_HOME will change the cache location from $HOME/.cache

Signed-off-by: Lalatendu Mohanty <lmohanty@redhat.com>
@LalatenduMohanty LalatenduMohanty force-pushed the golangci-lint_cache_permission_issue branch from a7c5256 to 798db4e Compare September 27, 2019 10:55
@LalatenduMohanty
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2019
@LalatenduMohanty
Copy link
Member Author

/test unit

@dgoodwin
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 27, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dgoodwin, LalatenduMohanty

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:
  • OWNERS [LalatenduMohanty,dgoodwin]

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

@openshift-merge-robot openshift-merge-robot merged commit beb334b into openshift:master Sep 27, 2019
@@ -208,5 +213,4 @@ clean:
# TODO: reenable once the CI permission denied on /.cache is fixed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops. I forgot to submit my review changes. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

@nitin-wise
Copy link

Could you clarify what this env var is and why it fixes the problem in commit messag

Will do.
It seems like an issue when go code running in container as non-root user, and the user does not exist in the container. Go by default disables the cache. It seems we will need to set GOCACHE explicitly when running a build as a nonexistent user (in our case it is root I think) [1] . Not sure what user ID we are expected to use in the CI system.

As per [2] $XDG_CACHE_HOME defines the base directory relative to which user specific non-essential data files should be stored. If $XDG_CACHE_HOME is either not set or empty, a default equal to $HOME/.cache should be used.

The idea is to set it to a location where the go program (in this case golangci-lint) have write access.

[1] golang/go#26280
[2] https://specifications.freedesktop.org/basedir-spec/0.6/ar01s03.html

Worked when XDG_CACHE_HOME = './' to bring the cache home to code path

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. lgtm Indicates that a PR is ready to be merged. 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.

6 participants