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

"cache add" with sha256 sum: "Failed to cache... repository can only contain the runes" #3822

Closed
kameshsampath opened this issue Mar 7, 2019 · 16 comments · Fixed by #3899
Closed
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. r/2019q2 Issue was last reviewed 2019q2

Comments

@kameshsampath
Copy link

Right now the minikube cache command allows to cache only images with tag, it will be great to support caching images with SHAs

@kameshsampath kameshsampath changed the title Ability to cache image with SHA Ability to do minikube cache add with image@SHA Mar 7, 2019
@tstromberg tstromberg added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. labels Mar 7, 2019
@tstromberg
Copy link
Contributor

That sounds totally reasonable, and more like a bug than a feature request. What command-line are you using, and what currently happens when you try to add an image to a cache with a SHA?

@tstromberg tstromberg removed the kind/feature Categorizes issue or PR as related to a new feature. label Mar 7, 2019
@kameshsampath
Copy link
Author

kameshsampath commented Mar 8, 2019

@tstromberg here is an example of the cache add with sha256 with error

minikube cache add gcr.io/kaniko-project/executor@sha256:d9fe474f80b73808dc12b54f45f5fc90f7856d9fc699d4a5e79d968a1aef1a72

Error

💣  Failed to cache and load images: caching images: caching image ~/.minikube/cache/images/gcr.io/kaniko-project/executor@sha256_d9fe474f80b73808dc12b54f45f5fc90f7856d9fc699d4a5e79d968a1aef1a72: creating docker image name: repository can only contain the runes `abcdefghijklmnopqrstuvwxyz0123456789_-./`: kaniko-project/executor@sha256

😿  Sorry that minikube crashed. If this was unexpected, we would love to hear from you:
👉  https://github.com/kubernetes/minikube/issues/new

@tstromberg tstromberg changed the title Ability to do minikube cache add with image@SHA "cache add" with sha256 sum: "Failed to cache... repository can only contain the runes" Mar 8, 2019
@tstromberg
Copy link
Contributor

Thanks for the additional information - it makes it much clearer what's going on.

I'm not sure what needs to be changed to make this work, but would be happy to approve any PR's that address this issue.

@tstromberg tstromberg added the priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. label Mar 8, 2019
@kameshsampath
Copy link
Author

if I get bandwidth will try sending PR your way .

@afbjorklund
Copy link
Collaborator

I think we should be using ParseReference, since that allows both tags and digests ?

https://github.com/google/go-containerregistry/blob/master/pkg/name/ref.go#L41_L50

	tag, err := name.NewTag(image, name.WeakValidation)
	if err != nil {
		return errors.Wrap(err, "creating docker image name")
	}

https://github.com/kubernetes/minikube/blob/master/pkg/minikube/machine/cache_images.go#L300

@afbjorklund
Copy link
Collaborator

afbjorklund commented Mar 8, 2019

Gaah, unfortunately there is currently no tarball Write that accepts Digest (or Reference)...

	td := tarDescriptor{
		singleImageTarDescriptor{
			Config:   cfgName.String(),
			RepoTags: []string{tag.String()},
			Layers:   layerFiles,
		},
	}

For a digest tarball, this is supposed to say "RepoTags":null in JSON - doesn't work with tag

@afbjorklund
Copy link
Collaborator

@kameshsampath : Did a sample implementation here: master...afbjorklund:reference

But those vendor changes should go upstream, and they added some more features to write.go.

@afbjorklund
Copy link
Collaborator

Added google/go-containerregistry#404

@kameshsampath
Copy link
Author

@afbjorklund - thanks, not sure I make sense here can we reuse this code ? https://github.com/knative/serving/blob/master/pkg/reconciler/v1alpha1/revision/resolve.go

@afbjorklund
Copy link
Collaborator

That code looks very similar, i.e. they are both using name.Tag and name.Digest ?

The main remaining problem with g/go-cr is that it is impossible to load digests.
i.e. the API only takes Tag as parameters, and for a Digest that would be nil

But minikube doesn't really care, since we only use it to save tarballs anyway...

In case it wasn't obvious, the above code snippet does fix loading of digests.
It is just a matter of how to get the feature included in the vendored upstream.

@kameshsampath
Copy link
Author

kameshsampath commented Mar 10, 2019

CC: @vdemeester, Vincent did patch the go/go-cr for another PR, he might be able to help us.

@vdemeester
Copy link

@afbjorklund upstream's PR got merged 👼 Do you want to open a PR here or should I go ahead ? 👼

@afbjorklund
Copy link
Collaborator

I'm giving it a try: dep ensure -update github.com/google/go-containerregistry

@afbjorklund
Copy link
Collaborator

afbjorklund commented Mar 18, 2019

Oops, look like I broke upstream:

pkg/minikube/machine/cache_images.go:316:22: too many arguments in call to tarball.Write
	have (name.Tag, v1.Image, nil, *os.File)
	want (name.Reference, v1.Image, io.Writer)

My understanding of Go inheritance is limited.


EDIT: fortunately, it wasn't me. Read too fast, the ref is fine - it was someone else that broke API:

google/go-containerregistry@0316795

@imjasonh
Copy link

That was me. 👋

Luckily the fix is straightforward, just remove the nil argument and it should work again.

Sorry for the speedbump, we're hoping to stabilize the go-containerregistry library soon, and do real releases.

@afbjorklund
Copy link
Collaborator

Works as advertised, the only difference is in the RepoTags:

--- a/manifest.json	1970-01-01 01:00:00.000000000 +0100
+++ b/manifest.json	1970-01-01 01:00:00.000000000 +0100
@@ -1 +1 @@
-[{"Config":"sha256:025ab64f8cc830417dc6d85b1f2cbdff9030d1ba1bd781a44f3191f53450214b","RepoTags":["gcr.io/kaniko-project/executor:latest"],"Layers":["20aeb61b9e385a5ee65b8985abaa1b3dd01a301247c9ceb8048ff4dd70da81a9.tar.gz","76dd575757341869d3268e5a80f6492487a3ff4f2cf2fb220bf1280e99ce49a3.tar.gz","ec294f5524f9bb08d9e715bb4ff11c11d722fe46517408f8edc9c21378cca882.tar.gz","6352599e53cdf9f3c68b6f37ae5aa3e011f5f94386c839e63c5e2ca2b07eef8b.tar.gz","f5344ea33cc949b8da96ef152cc55add5428fdcace3436e14614c7833329398d.tar.gz","ec44e76f69b1fbdaa890e4724840a3c82c950680b78dc354ecdef905f9f9496e.tar.gz","ceb0b51a5b370acaa47fe3d52833b65252f3af2dc82bdcb3bd9619aafb6d5a25.tar.gz"]}]
\ No newline at end of file
+[{"Config":"sha256:025ab64f8cc830417dc6d85b1f2cbdff9030d1ba1bd781a44f3191f53450214b","RepoTags":null,"Layers":["20aeb61b9e385a5ee65b8985abaa1b3dd01a301247c9ceb8048ff4dd70da81a9.tar.gz","76dd575757341869d3268e5a80f6492487a3ff4f2cf2fb220bf1280e99ce49a3.tar.gz","ec294f5524f9bb08d9e715bb4ff11c11d722fe46517408f8edc9c21378cca882.tar.gz","6352599e53cdf9f3c68b6f37ae5aa3e011f5f94386c839e63c5e2ca2b07eef8b.tar.gz","f5344ea33cc949b8da96ef152cc55add5428fdcace3436e14614c7833329398d.tar.gz","ec44e76f69b1fbdaa890e4724840a3c82c950680b78dc354ecdef905f9f9496e.tar.gz","ceb0b51a5b370acaa47fe3d52833b65252f3af2dc82bdcb3bd9619aafb6d5a25.tar.gz"]}]
\ No newline at end of file

Similar to the output from docker save, identical RepoTags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. r/2019q2 Issue was last reviewed 2019q2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants