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

CNB lifecycle can't restore cached layer for go-mod #6

Closed
3 tasks done
bstick12 opened this issue Sep 6, 2019 · 4 comments
Closed
3 tasks done

CNB lifecycle can't restore cached layer for go-mod #6

bstick12 opened this issue Sep 6, 2019 · 4 comments

Comments

@bstick12
Copy link

bstick12 commented Sep 6, 2019

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?
N/A - Was testing the go-mod using kpack

What version of the buildpack you are using?
[email protected]

If you were attempting to accomplish a task, what was it you were attempting to do?
Rebuild an image using kpack where caching was enabled

What did you expect to happen?
The image would be re-built using the cached layers

What was the actual behavior?
The lifecycle of CNB fails at restore as the layer tar can be uncompressed

Restoring cached layer 'org.cloudfoundry.go-mod:go-mod'
Error: failed to restore: mkdir /layers/org.cloudfoundry.go-mod/go-mod/pkg/mod/github.com/bstick12/[email protected]/.circleci: permission denied

The previous layer is correctly used from cache

Restoring cached layer 'org.cloudfoundry.go-compiler:ac2a6efcc1f5ec8bdc0db0a988bb1d301d64b6d61b7e8d9e42f662fbb75a2b9b'
Restoring cached layer 'org.cloudfoundry.go-compiler:go'

The problem lies with the go module package paths. The package directories are not writeable. Apparently this is by design as discussed in golang/go#27161 and golang/go#27455 (comment)

  File: /layers/org.cloudfoundry.go-mod/go-mod/pkg/mod/github.com/bstick12/[email protected]/
  Size: 4096      	Blocks: 8          IO Block: 4096   directory
Device: 6ch/108d	Inode: 300555      Links: 4
Access: (0500/dr-x------)  Uid: ( 1000/     cnb)   Gid: ( 1000/     cnb)

This permission is preserved in the tarball

dr-x------ 1000/1000         0 1980-01-01 00:00 /layers/org.cloudfoundry.go-mod/go-mod/pkg/mod/github.com/bstick12/[email protected]
d

Since without a change to the tar or untaring process for this buildpack the caching process will break. Would be possible to disable caching.

Can you provide a sample app?

The behaviour should be the same for any go application that use go modules.

Please confirm where necessary:

  • I have included a log output
  • My log includes an error message
  • I have included steps for reproduction
@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/168351842

The labels on this github issue will be updated when the story is started.

@sclevine
Copy link
Member

sclevine commented Sep 7, 2019

Hi @bstick12,

This appears to be an issue with the CNB lifecycle. It should be possible to restore layers regardless of their permissions. The lifecycle should implement the equivalent of tar --delay-directory-restore -x....

Would you mind opening an issue here?
https://github.com/buildpack/lifecycle

@bstick12
Copy link
Author

bstick12 commented Sep 7, 2019

Thanks @sclevine. I've opened buildpacks/lifecycle#177

@thitch97
Copy link
Contributor

@bstick12 Closing this issue in favor of buildpack/lifecycle#177.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants