Skip to content

Add support for pushing/pulling to insecure registries#1870

Merged
balopat merged 4 commits intoGoogleContainerTools:masterfrom
nkubala:insecure-registry
Apr 10, 2019
Merged

Add support for pushing/pulling to insecure registries#1870
balopat merged 4 commits intoGoogleContainerTools:masterfrom
nkubala:insecure-registry

Conversation

@nkubala
Copy link
Copy Markdown
Contributor

@nkubala nkubala commented Mar 22, 2019

Fixed version of #1824

Now uses new name.Insecure option passed to name.ParseReference to ensure HTTP protocol is used for insecure registries on the go-containerregistry side.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Mar 23, 2019

Codecov Report

Merging #1870 into master will increase coverage by 0.12%.
The diff coverage is 45.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1870      +/-   ##
==========================================
+ Coverage   52.08%   52.21%   +0.12%     
==========================================
  Files         179      180       +1     
  Lines        7921     7956      +35     
==========================================
+ Hits         4126     4154      +28     
  Misses       3413     3413              
- Partials      382      389       +7
Impacted Files Coverage Δ
pkg/skaffold/schema/latest/config.go 100% <ø> (ø) ⬆️
pkg/skaffold/config/options.go 89.47% <ø> (ø) ⬆️
pkg/skaffold/debug/debug.go 44.82% <0%> (ø) ⬆️
pkg/skaffold/plugin/environments/gcb/types.go 0% <0%> (ø) ⬆️
pkg/skaffold/build/local/local.go 39.68% <0%> (ø) ⬆️
pkg/skaffold/runner/diagnose.go 0% <0%> (ø)
pkg/skaffold/build/kaniko/run.go 37.14% <0%> (ø) ⬆️
pkg/skaffold/plugin/builders/bazel/local.go 17.09% <0%> (ø) ⬆️
pkg/skaffold/build/local/jib_gradle.go 0% <0%> (ø) ⬆️
pkg/skaffold/build/cache/save.go 20.68% <0%> (ø) ⬆️
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd0eb85...e0739ec. Read the comment docs.

Copy link
Copy Markdown
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

I have one problem with this - insecureRegistries is passed into a lot of places, impacting the API of a lot of objects - I think we should sit down and see if we can create a design where less methods are impacted - maybe wire it through other objects.

originalDockerClient := newDockerCilent
newDockerCilent = func() (docker.LocalDaemon, error) {
return docker.NewLocalDaemon(test.api, nil), nil
originalDockerClient := newDockerClient
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can make this simpler by

  1. Calling the defer function using the original stored value and then setting the value
defer func( f func (map[string]bool) (docker.LocalDaemon, error)) { newDockerClinet = f }(newDockerClient)
newDockerClient = func (map[string]bool) (docker.LocalDaemon, error) {
 return docker.NewLocalDaemon(test.api, nil, test.insecureRegistries), nil
}

That ways, the originalDockerClient value is already captured in the function call.
Along the lines that @dgageot suggested here

if isInsecure(ref.Context().Registry.Name(), insecureRegistries) {
ref, err = getInsecureRegistryImpl(identifier)
if err != nil {
logrus.Warnf("error getting insecure registry: %s\nremote references may not be retrieved", err.Error())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry, i am not aware of how the go container registry works.
In case we see an error when parsing an insecure registry, we still try to fetch the image? Shd we not fail instead of warning?
Or is there a case where you can still retrieve the insecure image.
#failFast.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

mmm yeah it's unlikely that retrieving the image will work if this fails, but I don't see the harm in trying. remote.Image should be a pretty inexpensive call, and if that fails skaffold will fail.

shouldErr: true,
},
{
name: "secure image provided in insecure registries list",
Copy link
Copy Markdown
Contributor

@tejal29 tejal29 Mar 25, 2019

Choose a reason for hiding this comment

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

I think this case is testing if user incorrectly adds a secure registry to insecure list by using a hint "test.insecure".
Right now, we do not validate the insecureRegistry list the code will still call getInsecureRegistryImpl which is correct.
Shd we not test this? or add a todo to ring this test back in when we have some validation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not sure I understand what you're saying here. if you're asking about validation of the insecure registry list (as in, each specified registry is actually "insecure"), it's not really possible to validate this without pinging each individual registry before making the remote.Image call. if any registries are passed by the user as "insecure", the list will be populated and getInsecureRegistryImpl will be called (which is part of what this test is testing). does that answer your question?

return nil, errors.Wrap(err, "parsing initial ref")
}

if isInsecure(ref.Context().Registry.Name(), insecureRegistries) {
Copy link
Copy Markdown
Contributor

@corneliusweig corneliusweig Mar 26, 2019

Choose a reason for hiding this comment

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

As far as I understand, the insecureRegistries is only required here.
Would an package init which retrieves the insecure registries from the config file be a valid approach? That would have the advantage to not scatter the configuration over large portions of the codebase.
On second thoughts: init is probably a nightmare for testing...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah we're thinking along the lines of creating a RunContext that could be passed down from the runner rather.

@balopat
Copy link
Copy Markdown
Contributor

balopat commented Apr 3, 2019

#1885 was merged - this needs rebase/rewrite to use RunContext

@balopat
Copy link
Copy Markdown
Contributor

balopat commented Apr 10, 2019

Added some commits as we reviewed it together + opened #1943 for a redesign of the image management.

@balopat balopat merged commit 26ae49f into GoogleContainerTools:master Apr 10, 2019
@tejal29 tejal29 mentioned this pull request Apr 12, 2019
@nkubala nkubala deleted the insecure-registry branch June 12, 2019 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants