Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

Conversation

@cgonyeo
Copy link
Member

@cgonyeo cgonyeo commented Jun 10, 2016

This commit adds support for the docker v2.2 image format and OCI image
format. When the remote registry supports the docker v2 HTTP API,
docker2aci will add the media types for v2.1, v2.2 and OCI to the Accept
header on the manifest request, and handle the returned manifest version
accordingly.

@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 10, 2016

Right now docker2aci is relying on the docker hub rewriting manifests into the v2.1 schema for it.

Also I want to write a test or two for this before it gets merged, so that will come next week.

@jonboulle
Copy link
Contributor

@iaguis @s-urbaniak review?


copier := progressutil.NewCopyProgressPrinter()

var errChannels []chan error
Copy link

@s-urbaniak s-urbaniak Jun 13, 2016

Choose a reason for hiding this comment

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

any reason why we cannot use a single (buffered) channel)? The amount of err's is known in forehand.

@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 13, 2016

@s-urbaniak switched to using a single buffered channel, as per your suggestion

@s-urbaniak
Copy link

@dgonyeo that was quick ;-) thanks for the quick update. How did you test this locally? I'd like to play with it tomorrow morning.

@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 13, 2016

I pointed it at the docker hub (i.e. ./bin/docker2aci docker://nginx) and used print statements to see that my new code paths were being hit. Not graceful, but works.

For the tests I'm going to write this week I intend to spin up a local distribution, but docker2aci gets upset when the local distribution responds to its https request with http, so I might need to tweak --insecure-allow-http to support that.

}
for i := 0; i < len(layerIDs); i++ {
res := <-resultChan
defer res.closer.Close()

Choose a reason for hiding this comment

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

this will panic if res.closer is nil which can happen if you return an err.

Choose a reason for hiding this comment

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

I guess we can just swap with the err check below to prevent this.

@cgonyeo cgonyeo force-pushed the master branch 2 times, most recently from 2240086 to e7ff0f6 Compare June 14, 2016 17:54
@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 14, 2016

@s-urbaniak how's it look now:

  • a buffered channel is used to receive results from the goroutines started up
  • the closers and files, if not nil, have a deferred close (realized we could also leave the files open here if an error was hit a few lines down)
  • If the err is not nil, it's put in a list
  • After getting the responses from each goroutine, if the list of errors is not empty, return the first error that was encountered

@s-urbaniak
Copy link

@dgonyeo 👍 ... those dreaded resources ;-)

Another idea I had to omit those if closer/file != nil checks: we could also return a https://golang.org/pkg/io/ioutil/#NopCloser in case of an err .. but I leave that to you if that makes code any "prettier".

lgtm from my side, didn't make it to test today though, will do so tomorrow.

@s-urbaniak
Copy link

@dgonyeo out of curiosity: why do we need to bubble up those response bodies (closer) up through the channel? Can't we close them earlier?

@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 15, 2016

@s-urbaniak: those response bodies can't be closed until the copier.PrintAndWait call finishes, as the CopyProgressPrinter is still copying data from them. Maybe it would be cleaner to have the CopyProgressPrinter have a function like CloseAllInputs that could be called after the transfers are complete.

@runcom runcom mentioned this pull request Jun 15, 2016
@jonboulle
Copy link
Contributor

bump - what's left? more review?

@s-urbaniak
Copy link

Still lgtm from my side, just had a small implementation question.

@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 17, 2016

Just realized that I never correctly added the annotations to the new manifest after doing the v2.2 -> AppC manifest conversion, so just updated this commit to fix that.

@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 20, 2016

And just added a commit that tweaks the tests to run them against a local registry in addition to running them on local files. The tests aren't as comprehensive as I wanted, but I couldn't find an easy way to generate/seed the registry with differing versions of docker images. This at least hits the fetching logic a few times.

@jonboulle
Copy link
Contributor

@s-urbaniak final review?

if res.err != nil {
errs = append(errs, res.err)
}
layerFiles[res.index] = res.file

Choose a reason for hiding this comment

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

res.file can be nil in case of an err, hence layerFiles[res.index] will be nil too.

Copy link
Contributor

Choose a reason for hiding this comment

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

seems like this is taken care of, res always has index now

@s-urbaniak
Copy link

s-urbaniak commented Jun 21, 2016

Found two small nits, else LGTM

@alban alban mentioned this pull request Jun 22, 2016
}()
}
var errs []error
for i := 0; i < len(layerIDs); i++ {
Copy link
Contributor

Choose a reason for hiding this comment

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

for res := range resultChan

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool, I didn't know you could range over channels. But resultChan never gets closed, so wouldn't the for loop never exit?

Choose a reason for hiding this comment

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

yes, if you don't close the channel, range will block forever.

@jonboulle
Copy link
Contributor

Couple of nits but also LGTM overall

This commit adds support for the docker v2.2 image format and OCI image
format. When the remote registry supports the docker v2 HTTP API,
docker2aci will add the media types for v2.1, v2.2 and OCI to the Accept
header on the manifest request, and handle the returned manifest version
accordingly.
@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 23, 2016

Oh, also added a gitignore because things in test/ were cluttering my git status.

@s-urbaniak
Copy link

@dgonyeo ping, is it ready for merge?

@cgonyeo
Copy link
Member Author

cgonyeo commented Jun 29, 2016

I believe it is.

@jonboulle
Copy link
Contributor

@dgonyeo @s-urbaniak

@s-urbaniak
Copy link

Sorry for the delay, I was confused who is supposed to merge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants