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

Allow importing tags from ImageStreams pointing to external registries #4853

Merged
merged 1 commit into from Oct 26, 2015

Conversation

soltysh
Copy link
Member

@soltysh soltysh commented Sep 29, 2015

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:

  1. if no tags are defined import all from default spec
  2. if tags are defined import only the ones defined, both from default spec and from external repos

@pweil- fyi

@ncdc
Copy link
Contributor

ncdc commented Sep 29, 2015

cc @pweil- @miminar

return c.done(stream, "", retryCount)
}

// getDefaultTags reads all tags from the stream's 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.

s/registry/image repository/

@soltysh soltysh changed the title [WIP] platformmanagement_public_514 - Allow importing tags from ImageStreams pointing to external registries Allow importing tags from ImageStreams pointing to external registries Oct 1, 2015
@soltysh
Copy link
Member Author

soltysh commented Oct 1, 2015

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),
Copy link
Contributor

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/

@soltysh
Copy link
Member Author

soltysh commented Oct 5, 2015

@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"`
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@ncdc
Copy link
Contributor

ncdc commented Oct 6, 2015

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):
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

@0xmichalis
Copy link
Contributor

Is this ready for review @soltysh ?

@soltysh
Copy link
Member Author

soltysh commented Oct 17, 2015

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.

@soltysh
Copy link
Member Author

soltysh commented Oct 20, 2015

This seems to fail only with hack/test-end-to-end-docker.sh, the local version works as expected. Let's give a jenkins another try.

@soltysh soltysh force-pushed the card514 branch 2 times, most recently from 85f449a to 5d8530f Compare October 20, 2015 17:32
@soltysh
Copy link
Member Author

soltysh commented Oct 20, 2015

I had to use ParseDockerImageReference instead of the initial DockerImageReferenceForStream in getTags method. ParseDockerImageReference was used in the original implementation, whereas the other one came from a discussion with @ncdc.

@soltysh
Copy link
Member Author

soltysh commented Oct 20, 2015

re-[test] the errors are flake, I can't repro locally.

@smarterclayton
Copy link
Contributor

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.

@soltysh
Copy link
Member Author

soltysh commented Oct 21, 2015

@smarterclayton I can't reproduce the error from hack/test-cmd.sh, it's working ok, I'll try to run that in the loop as you proposed, though. What worries me more is the hack/test-end-to-end-docker.sh which runs perfectly ok as hack/test-end-to-end.sh but the docker version fails on AWS. I'm working on it... stilll...

@soltysh
Copy link
Member Author

soltysh commented Oct 21, 2015

@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: Error creating image stream mapping: imageStream \"ruby-20-centos7\" cannot be updated: the object has been modified; please apply your changes to the latest version and try again. I've talked with @miminar and @ncdc I'm working on adding a retry to the ISM creation, that should solve our problem.

@soltysh
Copy link
Member Author

soltysh commented Oct 22, 2015

I'm waiting for #5301 to land and then I'll rebase to catch the solution to failing tests in this PR.

@openshift-bot openshift-bot removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 22, 2015
@soltysh
Copy link
Member Author

soltysh commented Oct 26, 2015

Rebased to pick up the solution to failing tests.

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to e496c31

@soltysh
Copy link
Member Author

soltysh commented Oct 26, 2015

Finally, 👊 upon having 2 LGTMs:
[merge]

@pweil-
Copy link
Contributor

pweil- commented Oct 26, 2015

🎉 🎈 🍰

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to e496c31

openshift-bot pushed a commit that referenced this pull request Oct 26, 2015
@openshift-bot openshift-bot merged commit a410188 into openshift:master Oct 26, 2015
@soltysh soltysh deleted the card514 branch October 27, 2015 08:28
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.

None yet

7 participants