Add validation preventing recycle of / in a hostPath PV

This commit is contained in:
Paul Morie
2016-08-22 14:45:46 -04:00
parent 45e557e237
commit d22ffb0402
2 changed files with 32 additions and 0 deletions

View File

@@ -549,6 +549,32 @@ func TestValidatePersistentVolumes(t *testing.T) {
},
}),
},
"host mount of / with recycle reclaim policy": {
isExpectedFailure: true,
volume: testVolume("bad-recycle-do-not-want", "", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/"},
},
PersistentVolumeReclaimPolicy: api.PersistentVolumeReclaimRecycle,
}),
},
"host mount of / with recycle reclaim policy 2": {
isExpectedFailure: true,
volume: testVolume("bad-recycle-do-not-want", "", api.PersistentVolumeSpec{
Capacity: api.ResourceList{
api.ResourceName(api.ResourceStorage): resource.MustParse("10G"),
},
AccessModes: []api.PersistentVolumeAccessMode{api.ReadWriteOnce},
PersistentVolumeSource: api.PersistentVolumeSource{
HostPath: &api.HostPathVolumeSource{Path: "/a/.."},
},
PersistentVolumeReclaimPolicy: api.PersistentVolumeReclaimRecycle,
}),
},
}
for name, scenario := range scenarios {