@@ -508,6 +508,28 @@ func SubpathTestPod(f *framework.Framework, subpath, volumeType string, source *
508
508
probeVolumeName = "liveness-probe-volume"
509
509
seLinuxOptions = & v1.SELinuxOptions {Level : "s0:c0,c1" }
510
510
)
511
+
512
+ volumeMount := v1.VolumeMount {Name : volumeName , MountPath : volumePath }
513
+ volumeSubpathMount := v1.VolumeMount {Name : volumeName , MountPath : volumePath , SubPath : subpath }
514
+ probeMount := v1.VolumeMount {Name : probeVolumeName , MountPath : probeVolumePath }
515
+
516
+ initSubpathContainer := e2epod .NewAgnhostContainer (
517
+ fmt .Sprintf ("test-init-subpath-%s" , suffix ),
518
+ []v1.VolumeMount {volumeSubpathMount , probeMount }, nil , "mounttest" )
519
+ initSubpathContainer .SecurityContext = e2evolume .GenerateSecurityContext (privilegedSecurityContext )
520
+ initVolumeContainer := e2epod .NewAgnhostContainer (
521
+ fmt .Sprintf ("test-init-volume-%s" , suffix ),
522
+ []v1.VolumeMount {volumeMount , probeMount }, nil , "mounttest" )
523
+ initVolumeContainer .SecurityContext = e2evolume .GenerateSecurityContext (privilegedSecurityContext )
524
+ subpathContainer := e2epod .NewAgnhostContainer (
525
+ fmt .Sprintf ("test-container-subpath-%s" , suffix ),
526
+ []v1.VolumeMount {volumeSubpathMount , probeMount }, nil , "mounttest" )
527
+ subpathContainer .SecurityContext = e2evolume .GenerateSecurityContext (privilegedSecurityContext )
528
+ volumeContainer := e2epod .NewAgnhostContainer (
529
+ fmt .Sprintf ("test-container-volume-%s" , suffix ),
530
+ []v1.VolumeMount {volumeMount , probeMount }, nil , "mounttest" )
531
+ volumeContainer .SecurityContext = e2evolume .GenerateSecurityContext (privilegedSecurityContext )
532
+
511
533
return & v1.Pod {
512
534
ObjectMeta : metav1.ObjectMeta {
513
535
Name : fmt .Sprintf ("pod-subpath-test-%s" , suffix ),
@@ -516,88 +538,17 @@ func SubpathTestPod(f *framework.Framework, subpath, volumeType string, source *
516
538
Spec : v1.PodSpec {
517
539
InitContainers : []v1.Container {
518
540
{
519
- Name : fmt .Sprintf ("init-volume-%s" , suffix ),
520
- Image : e2evolume .GetTestImage (imageutils .GetE2EImage (imageutils .BusyBox )),
521
- VolumeMounts : []v1.VolumeMount {
522
- {
523
- Name : volumeName ,
524
- MountPath : volumePath ,
525
- },
526
- {
527
- Name : probeVolumeName ,
528
- MountPath : probeVolumePath ,
529
- },
530
- },
531
- SecurityContext : e2evolume .GenerateSecurityContext (privilegedSecurityContext ),
532
- },
533
- {
534
- Name : fmt .Sprintf ("test-init-subpath-%s" , suffix ),
535
- Image : mountImage ,
536
- Args : []string {"mounttest" },
537
- VolumeMounts : []v1.VolumeMount {
538
- {
539
- Name : volumeName ,
540
- MountPath : volumePath ,
541
- SubPath : subpath ,
542
- },
543
- {
544
- Name : probeVolumeName ,
545
- MountPath : probeVolumePath ,
546
- },
547
- },
548
- SecurityContext : e2evolume .GenerateSecurityContext (privilegedSecurityContext ),
549
- },
550
- {
551
- Name : fmt .Sprintf ("test-init-volume-%s" , suffix ),
552
- Image : mountImage ,
553
- Args : []string {"mounttest" },
554
- VolumeMounts : []v1.VolumeMount {
555
- {
556
- Name : volumeName ,
557
- MountPath : volumePath ,
558
- },
559
- {
560
- Name : probeVolumeName ,
561
- MountPath : probeVolumePath ,
562
- },
563
- },
541
+ Name : fmt .Sprintf ("init-volume-%s" , suffix ),
542
+ Image : e2evolume .GetTestImage (imageutils .GetE2EImage (imageutils .BusyBox )),
543
+ VolumeMounts : []v1.VolumeMount {volumeMount , probeMount },
564
544
SecurityContext : e2evolume .GenerateSecurityContext (privilegedSecurityContext ),
565
545
},
546
+ initSubpathContainer ,
547
+ initVolumeContainer ,
566
548
},
567
549
Containers : []v1.Container {
568
- {
569
- Name : fmt .Sprintf ("test-container-subpath-%s" , suffix ),
570
- Image : mountImage ,
571
- Args : []string {"mounttest" },
572
- VolumeMounts : []v1.VolumeMount {
573
- {
574
- Name : volumeName ,
575
- MountPath : volumePath ,
576
- SubPath : subpath ,
577
- },
578
- {
579
- Name : probeVolumeName ,
580
- MountPath : probeVolumePath ,
581
- },
582
- },
583
- SecurityContext : e2evolume .GenerateSecurityContext (privilegedSecurityContext ),
584
- },
585
- {
586
- Name : fmt .Sprintf ("test-container-volume-%s" , suffix ),
587
- Image : mountImage ,
588
- Args : []string {"mounttest" },
589
- VolumeMounts : []v1.VolumeMount {
590
- {
591
- Name : volumeName ,
592
- MountPath : volumePath ,
593
- },
594
- {
595
- Name : probeVolumeName ,
596
- MountPath : probeVolumePath ,
597
- },
598
- },
599
- SecurityContext : e2evolume .GenerateSecurityContext (privilegedSecurityContext ),
600
- },
550
+ subpathContainer ,
551
+ volumeContainer ,
601
552
},
602
553
RestartPolicy : v1 .RestartPolicyNever ,
603
554
TerminationGracePeriodSeconds : & gracePeriod ,
0 commit comments