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
Allow importing tags from ImageStreams pointing to external registries #4853
Conversation
return c.done(stream, "", retryCount) | ||
} | ||
|
||
// getDefaultTags reads all tags from the stream's 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.
s/registry/image repository/
I'm done with the implementation, @ncdc ptal. |
// 2. spec.DockerImageRepository + tags defined - import all tags from default registry, | ||
// and all the specified which (if name matches) will overwrite the default ones. | ||
// Additionally: | ||
// for kind == DockerImage import or reference underlying image, iow. exact tag (no provided means latest), |
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.
s/no provided/not provided/
@ncdc comments addressed and reorganized the code per your suggestion. ptal. [test] in the mean time. |
@@ -63,6 +63,8 @@ type NamedTagReference struct { | |||
Name string `json:"name"` | |||
Annotations map[string]string `json:"annotations,omitempty"` | |||
From *kapi.ObjectReference `json:"from,omitempty"` | |||
// Referenace states if the tag will be imported. Default value is false, which means the tag will be imported. | |||
Reference bool `json:"reference,omitempty" description:"flag informing if tag is a reference (true) or is imported"` |
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.
if true consider this tag a reference only and do not attempt to import metadata about the image
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.
done.
I will review this tomorrow morning when I'm back from PTO. |
dockerImage, err = conn.ImageByTag(ref.Namespace, ref.Name, ref.Tag) | ||
} | ||
switch { | ||
case dockerregistry.IsRepositoryNotFound(err), dockerregistry.IsRegistryNotFound(err): |
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.
This is no longer the case where it should terminate an import. Instead, you need to make as much progress as possible and then fail at the end. It would be better to accumulate errors and continue. c.done()
should not be invoked in this loop. This iteration of the loop should be extracted into a function.
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 don't have any reasonable error handling for IS. Do we want to use
events for that or you're talking about just logging errors here? I agree
we should process as much as possible, but still we want to inform user
about import problems in a reasonable way.
On Oct 6, 2015 8:51 PM, "Clayton Coleman" notifications@github.com wrote:
In pkg/image/controller/controller.go
#4853 (comment):
var dockerImage *dockerregistry.Image
if image, ok := retrieved[ref.ID]; ok {
dockerImage = image
} else {
// TODO insecure applies to the stream's spec.dockerImageRepository, not necessarily to an external one!
conn, err := client.Connect(ref.Registry, insecure)
if err != nil {
return err
}
if len(ref.ID) > 0 {
dockerImage, err = conn.ImageByID(ref.Namespace, ref.Name, ref.ID)
} else {
dockerImage, err = conn.ImageByTag(ref.Namespace, ref.Name, ref.Tag)
}
switch {
case dockerregistry.IsRepositoryNotFound(err), dockerregistry.IsRegistryNotFound(err):
This is no longer the case where it should terminate an import. Instead,
you need to make as much progress as possible and then fail at the end. It
would be better to accumulate errors and continue. c.done() should not be
invoked in this loop. This iteration of the loop should be extracted into a
function.—
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/4853/files#r41306035.
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 do, it goes in the annotation. But you don't even need to do more than
report the first error.
On Tue, Oct 6, 2015 at 5:36 PM, Maciej Szulik notifications@github.com
wrote:
In pkg/image/controller/controller.go
#4853 (comment):
var dockerImage *dockerregistry.Image
if image, ok := retrieved[ref.ID]; ok {
dockerImage = image
} else {
// TODO insecure applies to the stream's spec.dockerImageRepository, not necessarily to an external one!
conn, err := client.Connect(ref.Registry, insecure)
if err != nil {
return err
}
if len(ref.ID) > 0 {
dockerImage, err = conn.ImageByID(ref.Namespace, ref.Name, ref.ID)
} else {
dockerImage, err = conn.ImageByTag(ref.Namespace, ref.Name, ref.Tag)
}
switch {
case dockerregistry.IsRepositoryNotFound(err), dockerregistry.IsRegistryNotFound(err):
We don't have any reasonable error handling for IS. Do we want to use
events for that or you're talking about just logging errors here? I agree
we should process as much as possible, but still we want to inform user
about import problems in a reasonable way.
… <#1503f1535551d805_>
On Oct 6, 2015 8:51 PM, "Clayton Coleman" notifications@github.com
wrote: In pkg/image/controller/controller.go <
https://github.com/openshift/origin/pull/4853#discussion_r41306035>: > +
var dockerImage *dockerregistry.Image > + if image, ok :=
retrieved[ref.ID]; ok { > + dockerImage = image > + } else { > + // TODO
insecure applies to the stream's spec.dockerImageRepository, not
necessarily to an external one! > + conn, err :=
client.Connect(ref.Registry, insecure) > + if err != nil { > + return err >
- } > + if len(ref.ID) > 0 { > + dockerImage, err =
conn.ImageByID(ref.Namespace, ref.Name, ref.ID) > + } else { > +
dockerImage, err = conn.ImageByTag(ref.Namespace, ref.Name, ref.Tag) > + }
- switch { > + case dockerregistry.IsRepositoryNotFound(err),
dockerregistry.IsRegistryNotFound(err): This is no longer the case where it
should terminate an import. Instead, you need to make as much progress as
possible and then fail at the end. It would be better to accumulate errors
and continue. c.done() should not be invoked in this loop. This iteration
of the loop should be extracted into a function. — Reply to this email
directly or view it on GitHub <
https://github.com/openshift/origin/pull/4853/files#r41306035>.—
Reply to this email directly or view it on GitHub
https://github.com/openshift/origin/pull/4853/files#r41325904.
Is this ready for review @soltysh ? |
I'm closing and reopening to kick travis, I'll also kick the jenkins to have it retested. All of the failures are passing on my local machine. |
This seems to fail only with |
85f449a
to
5d8530f
Compare
I had to use |
re-[test] the errors are flake, I can't repro locally. |
The test failure in hack/test-cmd.sh may be your changes. Can you run it on a loop on your laptop and verify it completes? Did not see that failure before your changes. |
@smarterclayton I can't reproduce the error from |
@smarterclayton I figured out what is causing this problem. Due to my changes in the import the time needed for importing the image is a bit longer than previously. This infects the flow in registry, where if IS is missing upon ISM creation we create new IS and right after that ISM, which is getting version mismatch error: |
I'm waiting for #5301 to land and then I'll rebase to catch the solution to failing tests in this PR. |
…s pointing to external registries.
Rebased to pick up the solution to failing tests. |
Evaluated for origin test up to e496c31 |
Finally, 👊 upon having 2 LGTMs: |
🎉 🎈 🍰 |
Evaluated for origin merge up to e496c31 |
Merged by openshift-bot
This is the initial version of improved importer, to address card 514.
@ncdc I know it's bit messy still, I'm working on getting it DRY-ed and most importantly fully tested, still I'd appreciate first raw pass, if this makes sense. The general flow is following:
@pweil- fyi