-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Conversation
@smarterclayton FYI |
@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. |
@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 ) |
There was a problem hiding this 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.
pkg/image/apis/image/helper.go
Outdated
// 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
pkg/image/apis/image/helper.go
Outdated
} | ||
|
||
type defaultRegistryHostnameRetriever struct { | ||
defaultFn func() (string, bool) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
pkg/image/apis/image/helper.go
Outdated
// 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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
pkg/cmd/server/api/v1/types.go
Outdated
// 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"` |
There was a problem hiding this comment.
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.
@soltysh comments addressed, thx! |
pkg/cmd/server/api/types.go
Outdated
// 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 |
There was a problem hiding this comment.
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
pkg/image/apis/image/helper.go
Outdated
// RegistryHostnameRetriever represents an interface for retrieving the hostname | ||
// of internal and external registry. | ||
type RegistryHostnameRetriever interface { | ||
InternalRegistryHostnameFn() func() (string, bool) |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
@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., |
/test extended_conformance_gce |
pkg/image/apis/image/helper.go
Outdated
} | ||
|
||
// InternalRegistryHostnameFn returns a function that can be used to lazy-load | ||
// the internal Docker Registry hostname. If the master configuration propertly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo
pkg/cmd/server/api/v1/types.go
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
image registry
pkg/cmd/server/api/v1/types.go
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
Pretty close, a couple of comments. |
@smarterclayton typos fixed and OPENSHIFT_DEFAULT_REGISTRY clarified in godoc. |
/lgtm |
[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 |
/retest Please review the full test history for this PR and help us cut down flakes. |
flake: #16025 /test extended_conformance_gce |
another deployment flake: #16025 /test extended_conformance_install_update |
/retest Please review the full test history for this PR and help us cut down flakes. |
@csrwng I am trying to understand how this PR will effect |
/test all [submit-queue is verifying that this PR is safe to merge] |
@mfojtik: The following test failed, say
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. |
Automatic merge from submit-queue (batch tested with PRs 15853, 15916, 16017, 16027, 16043) |
This PR introduces two new fields for the master config,
externalRegistryHostname
andinternalRegistryHostname
.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 theOPENSHIFT_DEFAULT_REGISTRY
.