Skip to content

Commit a549478

Browse files
Merge pull request #20623 from bparees/isi_import
skip import call when there is nothing to import
2 parents 35204ed + b0b2934 commit a549478

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pkg/image/controller/imagestream_controller.go

+4
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,10 @@ func handleImageStream(
265265
ImportPolicy: imageapi.TagImportPolicy{Insecure: insecure},
266266
}
267267
}
268+
if isi.Spec.Repository == nil && len(isi.Spec.Images) == 0 {
269+
glog.V(4).Infof("Did not find any tags or repository needing import")
270+
return nil, nil
271+
}
268272
result, err := client.ImageStreamImports(stream.Namespace).CreateWithoutTimeout(isi)
269273
if err != nil {
270274
if apierrs.IsNotFound(err) && isStatusErrorKind(err, "imageStream") {

pkg/image/controller/imagestream_controller_test.go

+22
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,28 @@ func TestHandleImageStream(t *testing.T) {
328328
},
329329
},
330330
},
331+
// spec tag with generation with current status generation will be ignored
332+
{
333+
stream: &imageapi.ImageStream{
334+
ObjectMeta: metav1.ObjectMeta{
335+
Annotations: map[string]string{imageapi.DockerImageRepositoryCheckAnnotation: metav1.Now().UTC().Format(time.RFC3339)},
336+
Name: "test",
337+
Namespace: "other",
338+
},
339+
Spec: imageapi.ImageStreamSpec{
340+
Tags: map[string]imageapi.TagReference{
341+
"latest": {
342+
From: &kapi.ObjectReference{Kind: "DockerImage", Name: "test/other:latest"},
343+
Generation: &two,
344+
},
345+
},
346+
},
347+
Status: imageapi.ImageStreamStatus{
348+
Tags: map[string]imageapi.TagEventList{"latest": {Items: []imageapi.TagEvent{{Generation: 2}}}},
349+
},
350+
},
351+
expected: nil,
352+
},
331353
}
332354

333355
for i, test := range testCases {

0 commit comments

Comments
 (0)