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

registry: report publicDockerImageRepository to image stream if configured #15853

Merged
merged 1 commit into from
Aug 30, 2017

Conversation

mfojtik
Copy link
Contributor

@mfojtik mfojtik commented Aug 18, 2017

This PR introduces two new fields for the master config, externalRegistryHostname and internalRegistryHostname.

The first one will be used as a hostname for newly added publicDockerImageRepository field and it will reveal a public Docker pull spec users should use to pull the image if the registry is exposed externally (via route, etc.).

The later is a replacement for OPENSHIFT_DEFAULT_REGISTRY environment variable (but that variable is still picked up to guarantee backward compatibility). If set it will override the OPENSHIFT_DEFAULT_REGISTRY.

@openshift-merge-robot openshift-merge-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 18, 2017
@openshift-merge-robot openshift-merge-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-api-review labels Aug 18, 2017
@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 18, 2017

@smarterclayton FYI

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 18, 2017

@openshift/api-review the two new master config fields need review... i placed them under image policy as I don't want to invent new top-level struct and we already have allowed registries/etc. there.

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 18, 2017

@smarterclayton i guess we should also update the describer to report the public pull over the internal pull spec (if the public pull spec is non-zero), thoughts?

Also I guess the web console wants to pickup the public pull spec to make users happier ;-) (cc @spadgett )

@mfojtik mfojtik changed the title WIP: registry: report publicDockerImageRepository to image stream if configured registry: report publicDockerImageRepository to image stream if configured Aug 18, 2017
@spadgett
Copy link
Member

Also I guess the web console wants to pickup the public pull spec to make users happier ;-) (cc @spadgett )

Nice, thanks @mfojtik

cc @petervo @stefwalter @thomasmckay

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

Here's my comments.

// RegistryHostnameRetriever.
// The first argument is a function that lazy-loads the value of
// OPENSHIFT_DEFAULT_REGISTRY environment variable.
func DefaultRegistryHostnameRetriever(defaultFn func() (string, bool), external, internal string) RegistryHostnameRetriever {
Copy link
Contributor

Choose a reason for hiding this comment

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

With this function type being repeated over and over again, I'd suggest to leave the old DefaultRegistryFunc type definition and use that instead of copy&pasting this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DefaultRegistryFunc sounds misleading and you will have to repeat that instead of this so it does not fix the problem. I like DefaultRegistryHostnameRetriever better because it matches the interface name.

}

type defaultRegistryHostnameRetriever struct {
defaultFn func() (string, bool)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest naming this env/backwards/else type of function rather than default. Because it's not default.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

@@ -16,16 +16,16 @@ type Strategy struct {
runtime.ObjectTyper
names.NameGenerator

defaultRegistry imageapi.DefaultRegistry
registry imageapi.RegistryHostnameRetriever
Copy link
Contributor

Choose a reason for hiding this comment

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

registryHostnameRetriever

return &strategy{
ObjectTyper: kapi.Scheme,
allowedRegistries: registries,
registryFn: registryFn,
registry: registry,
Copy link
Contributor

Choose a reason for hiding this comment

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

registryHostnameRetriever, please. registry in this context will be misleading.

// the internal Docker Registry hostname. If the master configuration propertly
// InternalRegistryHostname is set, it will prefer that over the lazy-loaded
// environment variable 'OPENSHIFT_DEFAULT_REGISTRY'.
func (r *defaultRegistryHostnameRetriever) InternalRegistryHostnameFn() func() (string, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we just return the result of the invocation rather than the function itself? It looks like an overkill to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we still need to lazy-load the env variable from the cache, so we can't just return the result of invocation here.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's just a detail of the implementation - the point of returning false was "not resolved yet"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@smarterclayton i don't get this... if you don't set the env var when openshift process is starting, how will this succeed when lazy loaded? more thinking about this I guess this should just read the var when we start and be done with it :-) Makes the interface/usage much easier.

@@ -46,7 +46,7 @@ func (s *strategy) ValidateAllowedRegistries(isi *imageapi.ImageStreamImport) fi
allowedRegistries := *s.allowedRegistries
// FIXME: The registryFn won't return the registry location until the registry service
Copy link
Contributor

Choose a reason for hiding this comment

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

That FIXME is for removal with the static configs.

// InternalRegistryHostname sets the hostname for the default internal Docker
// Registry. This can be overriden by using OPENSHIFT_DEFAULT_REGISTRY
// environment variable.
InternalRegistryHostname string `json:"internalRegistryHostname"`
Copy link
Contributor

Choose a reason for hiding this comment

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

omitempty for both fields, since we allow empty values.

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 18, 2017

@soltysh comments addressed, thx!

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 18, 2017
@openshift-merge-robot openshift-merge-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 18, 2017
// Registry. The external hostname should be set only when the registry is
// exposed externally. The value is used in 'publicDockerImageRepository'
// field in ImageStreams.
ExternalRegistryHostname string
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify in godoc that this is host and host:port

// RegistryHostnameRetriever represents an interface for retrieving the hostname
// of internal and external registry.
type RegistryHostnameRetriever interface {
InternalRegistryHostnameFn() func() (string, bool)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this, it should be an interface still. You can pass separate small interfaces down.

Copy link
Contributor

@smarterclayton smarterclayton left a comment

Choose a reason for hiding this comment

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

Get rid of the fn() stuff

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 24, 2017

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 25, 2017

@smarterclayton reworked the interface and implementation (i realized that I can pass the function without wrapping it up in another function), it is much cleaner now.,

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 25, 2017

/test extended_conformance_gce

}

// InternalRegistryHostnameFn returns a function that can be used to lazy-load
// the internal Docker Registry hostname. If the master configuration propertly
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo

@@ -372,6 +372,15 @@ type ImagePolicyConfig struct {
// this policy - typically only administrators or system integrations will have those
// permissions.
AllowedRegistriesForImport *AllowedRegistries `json:"allowedRegistriesForImport,omitempty"`
// InternalRegistryHostname sets the hostname for the default internal Docker
Copy link
Contributor

Choose a reason for hiding this comment

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

image registry

@@ -372,6 +372,15 @@ type ImagePolicyConfig struct {
// this policy - typically only administrators or system integrations will have those
// permissions.
AllowedRegistriesForImport *AllowedRegistries `json:"allowedRegistriesForImport,omitempty"`
// InternalRegistryHostname sets the hostname for the default internal Docker
// Registry. This can be overriden by using OPENSHIFT_DEFAULT_REGISTRY
Copy link
Contributor

Choose a reason for hiding this comment

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

Can it? I thought you say down below it is not overriden.

@smarterclayton
Copy link
Contributor

Pretty close, a couple of comments.

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 28, 2017

@smarterclayton typos fixed and OPENSHIFT_DEFAULT_REGISTRY clarified in godoc.

@smarterclayton
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 28, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mfojtik, smarterclayton

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 29, 2017

flake: #16025

/test extended_conformance_gce

@mfojtik
Copy link
Contributor Author

mfojtik commented Aug 29, 2017

another deployment flake: #16025

/test extended_conformance_install_update

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@LalatenduMohanty
Copy link
Member

@csrwng I am trying to understand how this PR will effect cluster up. As it will help me understand if it effects Minishift. Any pointers?

@openshift-merge-robot
Copy link
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-ci-robot
Copy link

@mfojtik: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/extended_conformance_install_update 10fcce5 link /test extended_conformance_install_update

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 15853, 15916, 16017, 16027, 16043)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. needs-api-review size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants