@@ -21,6 +21,7 @@ import (
21
21
"k8s.io/client-go/rest/fake"
22
22
clientgotesting "k8s.io/client-go/testing"
23
23
kapi "k8s.io/kubernetes/pkg/api"
24
+ kapisext "k8s.io/kubernetes/pkg/apis/extensions"
24
25
"k8s.io/kubernetes/staging/src/k8s.io/apimachinery/pkg/util/diff"
25
26
26
27
"github.com/openshift/origin/pkg/api/graph"
@@ -244,6 +245,26 @@ func rc(namespace, name string, containerImages ...string) kapi.ReplicationContr
244
245
}
245
246
}
246
247
248
+ func dsList (dss ... kapisext.DaemonSet ) kapisext.DaemonSetList {
249
+ return kapisext.DaemonSetList {
250
+ Items : dss ,
251
+ }
252
+ }
253
+
254
+ func ds (namespace , name string , containerImages ... string ) kapisext.DaemonSet {
255
+ return kapisext.DaemonSet {
256
+ ObjectMeta : metav1.ObjectMeta {
257
+ Namespace : namespace ,
258
+ Name : name ,
259
+ },
260
+ Spec : kapisext.DaemonSetSpec {
261
+ Template : kapi.PodTemplateSpec {
262
+ Spec : podSpec (containerImages ... ),
263
+ },
264
+ },
265
+ }
266
+ }
267
+
247
268
func dcList (dcs ... deployapi.DeploymentConfig ) deployapi.DeploymentConfigList {
248
269
return deployapi.DeploymentConfigList {
249
270
Items : dcs ,
@@ -479,6 +500,7 @@ func TestImagePruning(t *testing.T) {
479
500
rcs kapi.ReplicationControllerList
480
501
bcs buildapi.BuildConfigList
481
502
builds buildapi.BuildList
503
+ dss kapisext.DaemonSetList
482
504
dcs deployapi.DeploymentConfigList
483
505
limits map [string ][]* kapi.LimitRange
484
506
expectedImageDeletions []string
@@ -634,6 +656,15 @@ func TestImagePruning(t *testing.T) {
634
656
expectedImageDeletions : []string {},
635
657
},
636
658
659
+ "referenced by daemonset - don't prune" : {
660
+ images : imageList (
661
+ image ("sha256:0000000000000000000000000000000000000000000000000000000000000000" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" ),
662
+ image ("sha256:0000000000000000000000000000000000000000000000000000000000000001" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000001" ),
663
+ ),
664
+ dss : dsList (ds ("foo" , "rc1" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" )),
665
+ expectedImageDeletions : []string {"sha256:0000000000000000000000000000000000000000000000000000000000000001" },
666
+ },
667
+
637
668
"referenced by bc - sti - ImageStreamImage - don't prune" : {
638
669
images : imageList (image ("sha256:0000000000000000000000000000000000000000000000000000000000000000" , registryHost + "/foo/bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" )),
639
670
bcs : bcList (bc ("foo" , "bc1" , "source" , "ImageStreamImage" , "foo" , "bar@sha256:0000000000000000000000000000000000000000000000000000000000000000" )),
@@ -1143,6 +1174,7 @@ func TestImagePruning(t *testing.T) {
1143
1174
RCs : & test .rcs ,
1144
1175
BCs : & test .bcs ,
1145
1176
Builds : & test .builds ,
1177
+ DSs : & test .dss ,
1146
1178
DCs : & test .dcs ,
1147
1179
LimitRanges : test .limits ,
1148
1180
RegistryURL : & url.URL {Scheme : "https" , Host : registryHost },
@@ -1389,6 +1421,7 @@ func TestRegistryPruning(t *testing.T) {
1389
1421
RCs : & kapi.ReplicationControllerList {},
1390
1422
BCs : & buildapi.BuildConfigList {},
1391
1423
Builds : & buildapi.BuildList {},
1424
+ DSs : & kapisext.DaemonSetList {},
1392
1425
DCs : & deployapi.DeploymentConfigList {},
1393
1426
RegistryURL : & url.URL {Scheme : "https" , Host : "registry1.io" },
1394
1427
}
@@ -1447,6 +1480,7 @@ func TestImageWithStrongAndWeakRefsIsNotPruned(t *testing.T) {
1447
1480
rcs := rcList ()
1448
1481
bcs := bcList ()
1449
1482
builds := buildList ()
1483
+ dss := dsList ()
1450
1484
dcs := dcList ()
1451
1485
1452
1486
options := PrunerOptions {
@@ -1456,6 +1490,7 @@ func TestImageWithStrongAndWeakRefsIsNotPruned(t *testing.T) {
1456
1490
RCs : & rcs ,
1457
1491
BCs : & bcs ,
1458
1492
Builds : & builds ,
1493
+ DSs : & dss ,
1459
1494
DCs : & dcs ,
1460
1495
}
1461
1496
keepYoungerThan := 24 * time .Hour
0 commit comments