Skip to content

Commit

Permalink
Allow volumeDevices in ephemeral containers
Browse files Browse the repository at this point in the history
  • Loading branch information
verb committed Oct 20, 2021
1 parent d874cf8 commit d33bbb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/apis/core/validation/validation.go
Expand Up @@ -84,6 +84,7 @@ var allowedEphemeralContainerFields = map[string]bool{
"Env": true,
"Resources": false,
"VolumeMounts": true,
"VolumeDevices": true,
"LivenessProbe": false,
"ReadinessProbe": false,
"StartupProbe": false,
Expand Down
10 changes: 8 additions & 2 deletions pkg/apis/core/validation/validation_test.go
Expand Up @@ -6143,7 +6143,10 @@ func getResourceLimits(cpu, memory string) core.ResourceList {
func TestValidateEphemeralContainers(t *testing.T) {
containers := []core.Container{{Name: "ctr", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}}
initContainers := []core.Container{{Name: "ictr", Image: "iimage", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: "File"}}
vols := map[string]core.VolumeSource{"vol": {EmptyDir: &core.EmptyDirVolumeSource{}}}
vols := map[string]core.VolumeSource{
"blk": {PersistentVolumeClaim: &core.PersistentVolumeClaimVolumeSource{ClaimName: "pvc"}},
"vol": {EmptyDir: &core.EmptyDirVolumeSource{}},
}

// Success Cases
for title, ephemeralContainers := range map[string][]core.EphemeralContainer{
Expand All @@ -6161,7 +6164,7 @@ func TestValidateEphemeralContainers(t *testing.T) {
TargetContainerName: "ctr",
},
},
"All allowed Fields": {
"All allowed fields": {
{
EphemeralContainerCommon: core.EphemeralContainerCommon{

Expand All @@ -6184,6 +6187,9 @@ func TestValidateEphemeralContainers(t *testing.T) {
VolumeMounts: []core.VolumeMount{
{Name: "vol", MountPath: "/vol"},
},
VolumeDevices: []core.VolumeDevice{
{Name: "blk", DevicePath: "/dev/block"},
},
TerminationMessagePath: "/dev/termination-log",
TerminationMessagePolicy: "File",
ImagePullPolicy: "IfNotPresent",
Expand Down

0 comments on commit d33bbb8

Please sign in to comment.