Skip to content

Commit

Permalink
Merge pull request #20623 from bparees/isi_import
Browse files Browse the repository at this point in the history
skip import call when there is nothing to import
  • Loading branch information
openshift-merge-robot authored Aug 16, 2018
2 parents 35204ed + b0b2934 commit a549478
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/image/controller/imagestream_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ func handleImageStream(
ImportPolicy: imageapi.TagImportPolicy{Insecure: insecure},
}
}
if isi.Spec.Repository == nil && len(isi.Spec.Images) == 0 {
glog.V(4).Infof("Did not find any tags or repository needing import")
return nil, nil
}
result, err := client.ImageStreamImports(stream.Namespace).CreateWithoutTimeout(isi)
if err != nil {
if apierrs.IsNotFound(err) && isStatusErrorKind(err, "imageStream") {
Expand Down
22 changes: 22 additions & 0 deletions pkg/image/controller/imagestream_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,28 @@ func TestHandleImageStream(t *testing.T) {
},
},
},
// spec tag with generation with current status generation will be ignored
{
stream: &imageapi.ImageStream{
ObjectMeta: metav1.ObjectMeta{
Annotations: map[string]string{imageapi.DockerImageRepositoryCheckAnnotation: metav1.Now().UTC().Format(time.RFC3339)},
Name: "test",
Namespace: "other",
},
Spec: imageapi.ImageStreamSpec{
Tags: map[string]imageapi.TagReference{
"latest": {
From: &kapi.ObjectReference{Kind: "DockerImage", Name: "test/other:latest"},
Generation: &two,
},
},
},
Status: imageapi.ImageStreamStatus{
Tags: map[string]imageapi.TagEventList{"latest": {Items: []imageapi.TagEvent{{Generation: 2}}}},
},
},
expected: nil,
},
}

for i, test := range testCases {
Expand Down

0 comments on commit a549478

Please sign in to comment.