Skip to content

Commit 786c7ed

Browse files
Update openshift image layers API
1 parent adb5588 commit 786c7ed

File tree

2 files changed

+41
-0
lines changed
  • pkg/image/apiserver/registry/imagestream/etcd
  • test/extended/images

2 files changed

+41
-0
lines changed

pkg/image/apiserver/registry/imagestream/etcd/etcd.go

+3
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ func addImageStreamLayersFromCache(isl *imageapi.ImageStreamLayers, is *imageapi
206206
obj, _, _ := index.GetByKey(item.Image)
207207
entry, ok := obj.(*ImageLayers)
208208
if !ok {
209+
if _, ok := isl.Images[item.Image]; !ok {
210+
isl.Images[item.Image] = imageapi.ImageBlobReferences{ImageMissing: true}
211+
}
209212
missing = append(missing, item.Image)
210213
continue
211214
}

test/extended/images/layers.go

+38
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,44 @@ var _ = g.Describe("[Feature:ImageLayers] Image layer subresource", func() {
3434

3535
oc = exutil.NewCLI("image-layers", exutil.KubeConfigPath())
3636

37+
g.It("should identify a deleted image as missing", func() {
38+
client := imageclientset.NewForConfigOrDie(oc.AdminConfig()).Image()
39+
_, err := client.ImageStreams(oc.Namespace()).Create(&imageapi.ImageStream{
40+
ObjectMeta: metav1.ObjectMeta{
41+
Name: "test",
42+
},
43+
})
44+
o.Expect(err).NotTo(o.HaveOccurred())
45+
_, err = client.ImageStreamMappings(oc.Namespace()).Create(&imageapi.ImageStreamMapping{
46+
ObjectMeta: metav1.ObjectMeta{
47+
Name: "test",
48+
},
49+
Image: imageapi.Image{
50+
ObjectMeta: metav1.ObjectMeta{
51+
Name: "an_image_to_be_deleted",
52+
},
53+
DockerImageReference: "example.com/random/image:latest",
54+
},
55+
Tag: "missing",
56+
})
57+
o.Expect(err).NotTo(o.HaveOccurred())
58+
err = client.Images().Delete("an_image_to_be_deleted", nil)
59+
o.Expect(err).NotTo(o.HaveOccurred())
60+
err = wait.PollImmediate(time.Second, time.Minute, func() (bool, error) {
61+
layers, err := client.ImageStreams(oc.Namespace()).Layers("test", metav1.GetOptions{})
62+
if err != nil {
63+
return false, err
64+
}
65+
ref, ok := layers.Images["an_image_to_be_deleted"]
66+
if !ok {
67+
return false, nil
68+
}
69+
o.Expect(ref.ImageMissing).To(o.BeTrue())
70+
return true, nil
71+
})
72+
o.Expect(err).NotTo(o.HaveOccurred())
73+
})
74+
3775
g.It("should return layers from tagged images", func() {
3876
ns = []string{oc.Namespace()}
3977
client := imageclientset.NewForConfigOrDie(oc.UserConfig()).Image()

0 commit comments

Comments
 (0)