Skip to content

Allow getting images from registries over untrusted connection - #11690

Merged
openshift-bot merged 1 commit into
openshift:masterfrom
legionus:add-pullthroughinsecure
Nov 7, 2016
Merged

openshift-bot merged 1 commit into
openshift:masterfrom
legionus:add-pullthroughinsecure

Conversation

@legionus

@legionus legionus commented Nov 1, 2016

Copy link
Copy Markdown
Contributor

@legionus

legionus commented Nov 1, 2016

Copy link
Copy Markdown
Contributor Author

[test]

@miminar miminar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'd also welcome at least one test. Either an integration, e2e or extended one.

BlobRepositoryCacheTTLEnvVar = "REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_BLOBREPOSITORYCACHETTL"

// PullthroughInsecureEnvVar is a boolean environment variable that allows to get image from the remote
// registry using HTTP protocol. This option requires that the pullthrough is enabled.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Insecure flag allows for pulling not only over HTTP protocol but also over HTTPS with self-signed certificate or with generally over untrusted connection.

I like a description of --insecure flag of image-import command:

allow importing from registries that have invalid HTTPS certificates or are hosted via HTTP.

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.

@miminar Fixed

digestToStore: make(map[string]distribution.BlobStore),
repo: &repo,
digestToStore: make(map[string]distribution.BlobStore),
pullFromInsecureRegistries: pullthroughinsecure,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

pullthroughinsecure not defined?

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.

@miminar Fixed

pullthroughinsecure, err := getBoolOption(PullthroughInsecureEnvVar, "pullthroughinsecure", false, options)
if err != nil {
context.GetLogger(ctx).Error(err)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

pullthroughinsecure unused variable?

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.

@miminar Fixed

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.

This setting should really be per image stream. I'm fairly uncomfortable allowing MitM as a global setting. @liggitt your opinion.

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.

agree.

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.

@smarterclayton @liggitt So, I will start to use InsecureRepositoryAnnotation per imagestream and I will remove pullFromInsecureRegistries. Ok ?

@legionus
legionus force-pushed the add-pullthroughinsecure branch from 3e5ff94 to ad9403f Compare November 1, 2016 15:05
@legionus

legionus commented Nov 1, 2016

Copy link
Copy Markdown
Contributor Author

I'd also welcome at least one test. Either an integration, e2e or extended one.

@miminar We already have test for pullFromInsecureRegistries == true.

@miminar

miminar commented Nov 1, 2016

Copy link
Copy Markdown

We already have test for pullFromInsecureRegistries == true.

Yeah, but that doesn't really test whether the env var or config file option are recognized. I don't insist on another integration test though.

@miminar

miminar commented Nov 1, 2016

Copy link
Copy Markdown

@smarterclayton since this changes your original intention, can you approve the changes?

@miminar miminar left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@mfojtik mfojtik added this to the 1.4.0 milestone Nov 2, 2016
@legionus
legionus force-pushed the add-pullthroughinsecure branch from ad9403f to befde3e Compare November 3, 2016 15:40
@legionus legionus changed the title Make pullFromInsecureRegistries configurable Allow getting images from registries over untrusted connection Nov 3, 2016
@legionus

legionus commented Nov 3, 2016

Copy link
Copy Markdown
Contributor Author

@miminar @liggitt @smarterclayton please review again.

@liggitt

liggitt commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

is this a new feature, and is it required for 1.4?

@legionus

legionus commented Nov 3, 2016

Copy link
Copy Markdown
Contributor Author

@liggitt This is a new feature.

@liggitt

liggitt commented Nov 3, 2016

Copy link
Copy Markdown
Contributor

the change seems really contained, but this is really late. @smarterclayton, ruling?

@legionus
legionus force-pushed the add-pullthroughinsecure branch from befde3e to 3a26f14 Compare November 3, 2016 15:52
@legionus

legionus commented Nov 3, 2016

Copy link
Copy Markdown
Contributor Author

[test]

@smarterclayton

Copy link
Copy Markdown
Contributor

This LGTM and is low risk and is technically a bug anyway. [merge]

@smarterclayton

Copy link
Copy Markdown
Contributor

@Kargakis new race in configChange test trigger?

https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_integration/8159/consoleFull#-94697474756bf4006e4b05b79524e5923

--- FAIL: TestTriggers_configChange (4.99s)
deploy_trigger_test.go:666: Operation cannot be fulfilled on
deploymentconfigs "config": the object has been modified; please apply your
changes to the latest version and try again
FAIL

On Thu, Nov 3, 2016 at 1:53 PM, OpenShift Bot [email protected]
wrote:

continuous-integration/openshift-jenkins/test FAILURE (
https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11080/) (Base
Commit: 6abb256
6abb256
)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11690 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_pyI7ga3OExh0BknB9H__DGqthZmmks5q6h-agaJpZM4KmG3c
.

@smarterclayton

Copy link
Copy Markdown
Contributor

[test]

On Thu, Nov 3, 2016 at 2:12 PM, Clayton Coleman [email protected] wrote:

@Kargakis new race in configChange test trigger?

https://ci.openshift.redhat.com/jenkins/job/test_pull_
requests_origin_integration/8159/consoleFull#-
94697474756bf4006e4b05b79524e5923

--- FAIL: TestTriggers_configChange (4.99s)
deploy_trigger_test.go:666: Operation cannot be fulfilled on
deploymentconfigs "config": the object has been modified; please apply your
changes to the latest version and try again
FAIL

On Thu, Nov 3, 2016 at 1:53 PM, OpenShift Bot [email protected]
wrote:

continuous-integration/openshift-jenkins/test FAILURE (
https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11080/) (Base
Commit: 6abb256
6abb256
)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#11690 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABG_pyI7ga3OExh0BknB9H__DGqthZmmks5q6h-agaJpZM4KmG3c
.

@smarterclayton

Copy link
Copy Markdown
Contributor

PullthroughBlobServed failed

@0xmichalis

Copy link
Copy Markdown
Contributor

@Kargakis new race in configChange test trigger? https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin_integration/8159/consoleFull#-94697474756bf4006e4b05b79524e5923

Hm, we already retry conflicts for this test:


The test seems to get the dc controller in a hotloop? Will have a look tomorrow.

}

func runRegistry() error {
config := `version: 0.1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is already duplicated several times. Can we import it from elsewhere or rather load it either from a new fixture file or images/dockerregistry/config.yml?

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.

This is already duplicated several times.

When you say "several times" do you mean twice ? :)

No, we can't use images/dockerregistry/config.yml because it is not suitable for testing. In fact, even these two tests (where config placed in the string) are different. In my testcase pullthrough: true is required.

I can place it in test/integration/testdata if you want.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What about using go template? Take a look here: https://play.golang.org/p/SmtSYlmhj1

But instead of const string, we could use fixture file.

`
os.Setenv("DOCKER_REGISTRY_URL", "127.0.0.1:5000")

go dockerregistry.Execute(strings.NewReader(config))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there no way to terminate the registry once the test is over?

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.

You're right. No way.

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.

That's why integration runs each test as its own process.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That's why integration runs each test as its own process.

That's a relief.

return distribution.Descriptor{}, err
}

r.pullFromInsecureRegistries = false

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The pullFromInsecureRegistries should already have an appropriate value. It shouldn't be overridden here.

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.

An incorrect value can be set upon creation. That is why the TestPullthroughServeBlob failed.

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.

I also wanted to protect against possible changes that I made in a previous version of this PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An incorrect value can be set upon creation.

I don't get it. Decision made on upper level shall be respected unless overridden by image stream annotation. If there's an incorrect value passed, it should be fixed in upper levels.

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.

I agree with @smarterclayton and @liggitt and I think that this setting should be per imagestream. In this case we should ignore global value to avoid side effects.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I agree as well. I'm just saying that default value shouldn't be decided at such a low level.

By this change, r.pullFromInsecureRegistries is rendered totally useless. If it's no longer useful for pullthrough tests then please remove it and use local variable instead.

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.

If it's no longer useful for pullthrough tests then please remove it and use local variable instead.

Yes, change this variable is useless. I fixed the tests. I did not remove a single test. It works without using this global variable. Why do you consider this a problem?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There's now a useless (*repository).pullFromInsecureRegistries attribute not being used anywhere but here. It makes people and compilers read useless lines. And if the compiler is not smart enough, it also wastes memory when run.

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.

Oh come on! The (*pullthroughBlobStore).pullFromInsecureRegistries is boolean. The imagestream is retrieved in the remoteStat, but is used in the proxyStat. I see no reason to pass local variable through remoteStat -> findCandidateRepository -> proxyStat. I think is more readable to use private parameter. And we already have it - (*pullthroughBlobStore).pullFromInsecureRegistries.
Since this option has never been used, I decided that it can be used to pass annotation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't agree but I won't argue. We've spent too much time already talking about this trifle.

return nil
}

func TestPullThroughInSecure(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: s/InSecure/Insecure/

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.

@miminar Fixed

@legionus
legionus force-pushed the add-pullthroughinsecure branch from 3a26f14 to 0b3b478 Compare November 4, 2016 10:47
@legionus

legionus commented Nov 4, 2016

Copy link
Copy Markdown
Contributor Author

@smarterclayton PullthroughBlobServed fixed.

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin test up to 0b3b478

@openshift-bot

Copy link
Copy Markdown
Contributor

@smarterclayton

Copy link
Copy Markdown
Contributor

LGTM [merge]

@openshift-bot

openshift-bot commented Nov 5, 2016 •

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/11118/) (Image: devenv-rhel7_5327)

@mfojtik

mfojtik commented Nov 7, 2016

Copy link
Copy Markdown
Contributor

[merge]

@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin merge up to 0b3b478

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

Successfully merging this pull request may close these issues.

7 participants