Skip to content

Commit 88a0987

Browse files
author
Kubernetes Submit Queue
authored
Merge pull request kubernetes#68088 from msau42/fix-multizone
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md. Fix multizone gce pd subpath test **What this PR does / why we need it**: The format pod for readonly tests also needs to fill in the NodeSelector for inline gce pd volumes. Also rename "gce" driver to "gcepd" **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes kubernetes#68085 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
2 parents bd2370d + 233db36 commit 88a0987

File tree

4 files changed

+70
-60
lines changed

4 files changed

+70
-60
lines changed

test/e2e/storage/drivers/in_tree.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,23 +1046,23 @@ func deleteCinderVolume(name string) error {
10461046
}
10471047

10481048
// GCE
1049-
type gceDriver struct {
1049+
type gcePdDriver struct {
10501050
volumeName string
10511051

10521052
driverInfo DriverInfo
10531053
}
10541054

1055-
var _ TestDriver = &gceDriver{}
1056-
var _ PreprovisionedVolumeTestDriver = &gceDriver{}
1057-
var _ InlineVolumeTestDriver = &gceDriver{}
1058-
var _ PreprovisionedPVTestDriver = &gceDriver{}
1059-
var _ DynamicPVTestDriver = &gceDriver{}
1055+
var _ TestDriver = &gcePdDriver{}
1056+
var _ PreprovisionedVolumeTestDriver = &gcePdDriver{}
1057+
var _ InlineVolumeTestDriver = &gcePdDriver{}
1058+
var _ PreprovisionedPVTestDriver = &gcePdDriver{}
1059+
var _ DynamicPVTestDriver = &gcePdDriver{}
10601060

1061-
// InitGceDriver returns gceDriver that implements TestDriver interface
1062-
func InitGceDriver() TestDriver {
1063-
return &gceDriver{
1061+
// InitGceDriver returns gcePdDriver that implements TestDriver interface
1062+
func InitGcePdDriver() TestDriver {
1063+
return &gcePdDriver{
10641064
driverInfo: DriverInfo{
1065-
Name: "gce",
1065+
Name: "gcepd",
10661066
MaxFileSize: testpatterns.FileSizeMedium,
10671067
SupportedFsType: sets.NewString(
10681068
"", // Default fsType
@@ -1078,18 +1078,18 @@ func InitGceDriver() TestDriver {
10781078
}
10791079
}
10801080

1081-
func (g *gceDriver) GetDriverInfo() *DriverInfo {
1081+
func (g *gcePdDriver) GetDriverInfo() *DriverInfo {
10821082
return &g.driverInfo
10831083
}
10841084

1085-
func (g *gceDriver) SkipUnsupportedTest(pattern testpatterns.TestPattern) {
1085+
func (g *gcePdDriver) SkipUnsupportedTest(pattern testpatterns.TestPattern) {
10861086
framework.SkipUnlessProviderIs("gce", "gke")
10871087
if pattern.FsType == "xfs" {
10881088
framework.SkipUnlessNodeOSDistroIs("ubuntu", "custom")
10891089
}
10901090
}
10911091

1092-
func (g *gceDriver) GetVolumeSource(readOnly bool, fsType string) *v1.VolumeSource {
1092+
func (g *gcePdDriver) GetVolumeSource(readOnly bool, fsType string) *v1.VolumeSource {
10931093
volSource := v1.VolumeSource{
10941094
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
10951095
PDName: g.volumeName,
@@ -1102,7 +1102,7 @@ func (g *gceDriver) GetVolumeSource(readOnly bool, fsType string) *v1.VolumeSour
11021102
return &volSource
11031103
}
11041104

1105-
func (g *gceDriver) GetPersistentVolumeSource(readOnly bool, fsType string) *v1.PersistentVolumeSource {
1105+
func (g *gcePdDriver) GetPersistentVolumeSource(readOnly bool, fsType string) *v1.PersistentVolumeSource {
11061106
pvSource := v1.PersistentVolumeSource{
11071107
GCEPersistentDisk: &v1.GCEPersistentDiskVolumeSource{
11081108
PDName: g.volumeName,
@@ -1115,7 +1115,7 @@ func (g *gceDriver) GetPersistentVolumeSource(readOnly bool, fsType string) *v1.
11151115
return &pvSource
11161116
}
11171117

1118-
func (g *gceDriver) GetDynamicProvisionStorageClass(fsType string) *storagev1.StorageClass {
1118+
func (g *gcePdDriver) GetDynamicProvisionStorageClass(fsType string) *storagev1.StorageClass {
11191119
provisioner := "kubernetes.io/gce-pd"
11201120
parameters := map[string]string{}
11211121
if fsType != "" {
@@ -1127,13 +1127,13 @@ func (g *gceDriver) GetDynamicProvisionStorageClass(fsType string) *storagev1.St
11271127
return getStorageClass(provisioner, parameters, nil, ns, suffix)
11281128
}
11291129

1130-
func (g *gceDriver) CreateDriver() {
1130+
func (g *gcePdDriver) CreateDriver() {
11311131
}
11321132

1133-
func (g *gceDriver) CleanupDriver() {
1133+
func (g *gcePdDriver) CleanupDriver() {
11341134
}
11351135

1136-
func (g *gceDriver) CreateVolume(volType testpatterns.TestVolType) {
1136+
func (g *gcePdDriver) CreateVolume(volType testpatterns.TestVolType) {
11371137
if volType == testpatterns.InlineVolume {
11381138
// PD will be created in framework.TestContext.CloudConfig.Zone zone,
11391139
// so pods should be also scheduled there.
@@ -1147,7 +1147,7 @@ func (g *gceDriver) CreateVolume(volType testpatterns.TestVolType) {
11471147
Expect(err).NotTo(HaveOccurred())
11481148
}
11491149

1150-
func (g *gceDriver) DeleteVolume(volType testpatterns.TestVolType) {
1150+
func (g *gcePdDriver) DeleteVolume(volType testpatterns.TestVolType) {
11511151
framework.DeletePDWithRetry(g.volumeName)
11521152
}
11531153

test/e2e/storage/in_tree_volumes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ var testDrivers = []func() drivers.TestDriver{
3838
drivers.InitHostpathSymlinkDriver,
3939
drivers.InitEmptydirDriver,
4040
drivers.InitCinderDriver,
41-
drivers.InitGceDriver,
41+
drivers.InitGcePdDriver,
4242
drivers.InitVSphereDriver,
4343
drivers.InitAzureDriver,
4444
drivers.InitAwsDriver,

test/e2e/storage/subpath.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var _ = utils.SIGDescribe("Subpath", func() {
5757
Description: Containers in a pod can read content from a secret mounted volume which was configured with a subpath.
5858
*/
5959
framework.ConformanceIt("should support subpaths with secret pod", func() {
60-
pod := testsuites.TestPodSubpath(f, "secret-key", "secret", &v1.VolumeSource{Secret: &v1.SecretVolumeSource{SecretName: "my-secret"}}, privilegedSecurityContext)
60+
pod := testsuites.SubpathTestPod(f, "secret-key", "secret", &v1.VolumeSource{Secret: &v1.SecretVolumeSource{SecretName: "my-secret"}}, privilegedSecurityContext)
6161
testsuites.TestBasicSubpath(f, "secret-value", pod)
6262
})
6363

@@ -67,7 +67,7 @@ var _ = utils.SIGDescribe("Subpath", func() {
6767
Description: Containers in a pod can read content from a configmap mounted volume which was configured with a subpath.
6868
*/
6969
framework.ConformanceIt("should support subpaths with configmap pod", func() {
70-
pod := testsuites.TestPodSubpath(f, "configmap-key", "configmap", &v1.VolumeSource{ConfigMap: &v1.ConfigMapVolumeSource{LocalObjectReference: v1.LocalObjectReference{Name: "my-configmap"}}}, privilegedSecurityContext)
70+
pod := testsuites.SubpathTestPod(f, "configmap-key", "configmap", &v1.VolumeSource{ConfigMap: &v1.ConfigMapVolumeSource{LocalObjectReference: v1.LocalObjectReference{Name: "my-configmap"}}}, privilegedSecurityContext)
7171
testsuites.TestBasicSubpath(f, "configmap-value", pod)
7272
})
7373

@@ -77,7 +77,7 @@ var _ = utils.SIGDescribe("Subpath", func() {
7777
Description: Containers in a pod can read content from a configmap mounted volume which was configured with a subpath and also using a mountpath that is a specific file.
7878
*/
7979
framework.ConformanceIt("should support subpaths with configmap pod with mountPath of existing file", func() {
80-
pod := testsuites.TestPodSubpath(f, "configmap-key", "configmap", &v1.VolumeSource{ConfigMap: &v1.ConfigMapVolumeSource{LocalObjectReference: v1.LocalObjectReference{Name: "my-configmap"}}}, privilegedSecurityContext)
80+
pod := testsuites.SubpathTestPod(f, "configmap-key", "configmap", &v1.VolumeSource{ConfigMap: &v1.ConfigMapVolumeSource{LocalObjectReference: v1.LocalObjectReference{Name: "my-configmap"}}}, privilegedSecurityContext)
8181
file := "/etc/resolv.conf"
8282
pod.Spec.Containers[0].VolumeMounts[0].MountPath = file
8383
testsuites.TestBasicSubpathFile(f, "configmap-value", pod, file)
@@ -89,7 +89,7 @@ var _ = utils.SIGDescribe("Subpath", func() {
8989
Description: Containers in a pod can read content from a downwardAPI mounted volume which was configured with a subpath.
9090
*/
9191
framework.ConformanceIt("should support subpaths with downward pod", func() {
92-
pod := testsuites.TestPodSubpath(f, "downward/podname", "downwardAPI", &v1.VolumeSource{
92+
pod := testsuites.SubpathTestPod(f, "downward/podname", "downwardAPI", &v1.VolumeSource{
9393
DownwardAPI: &v1.DownwardAPIVolumeSource{
9494
Items: []v1.DownwardAPIVolumeFile{{Path: "downward/podname", FieldRef: &v1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "metadata.name"}}},
9595
},
@@ -103,7 +103,7 @@ var _ = utils.SIGDescribe("Subpath", func() {
103103
Description: Containers in a pod can read content from a projected mounted volume which was configured with a subpath.
104104
*/
105105
framework.ConformanceIt("should support subpaths with projected pod", func() {
106-
pod := testsuites.TestPodSubpath(f, "projected/configmap-key", "projected", &v1.VolumeSource{
106+
pod := testsuites.SubpathTestPod(f, "projected/configmap-key", "projected", &v1.VolumeSource{
107107
Projected: &v1.ProjectedVolumeSource{
108108
Sources: []v1.VolumeProjection{
109109
{ConfigMap: &v1.ConfigMapProjection{

test/e2e/storage/testsuites/subpath.go

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func createSubPathTestInput(pattern testpatterns.TestPattern, resource subPathTe
8989
filePathInVolume: filepath.Join(subPathDir, fileName),
9090
volType: resource.volType,
9191
pod: resource.pod,
92+
formatPod: resource.formatPod,
9293
volSource: resource.genericVolumeTestResource.volSource,
9394
roVol: resource.roVolSource,
9495
}
@@ -131,6 +132,7 @@ type subPathTestResource struct {
131132

132133
roVolSource *v1.VolumeSource
133134
pod *v1.Pod
135+
formatPod *v1.Pod
134136
}
135137

136138
var _ TestResource = &subPathTestResource{}
@@ -171,9 +173,13 @@ func (s *subPathTestResource) setupResource(driver drivers.TestDriver, pattern t
171173

172174
subPath := f.Namespace.Name
173175
config := dInfo.Config
174-
s.pod = TestPodSubpath(f, subPath, s.volType, s.volSource, true)
176+
s.pod = SubpathTestPod(f, subPath, s.volType, s.volSource, true)
175177
s.pod.Spec.NodeName = config.ClientNodeName
176178
s.pod.Spec.NodeSelector = config.NodeSelector
179+
180+
s.formatPod = volumeFormatPod(f, s.volSource)
181+
s.formatPod.Spec.NodeName = config.ClientNodeName
182+
s.formatPod.Spec.NodeSelector = config.NodeSelector
177183
}
178184

179185
func (s *subPathTestResource) cleanupResource(driver drivers.TestDriver, pattern testpatterns.TestPattern) {
@@ -196,6 +202,7 @@ type subPathTestInput struct {
196202
filePathInVolume string
197203
volType string
198204
pod *v1.Pod
205+
formatPod *v1.Pod
199206
volSource *v1.VolumeSource
200207
roVol *v1.VolumeSource
201208
}
@@ -359,7 +366,7 @@ func testSubPath(input *subPathTestInput) {
359366
}
360367

361368
// Format the volume while it's writable
362-
formatVolume(input.f, input.volSource)
369+
formatVolume(input.f, input.formatPod)
363370

364371
// Set volume source to read only
365372
input.pod.Spec.Volumes[0].VolumeSource = *input.roVol
@@ -387,8 +394,8 @@ func TestBasicSubpathFile(f *framework.Framework, contents string, pod *v1.Pod,
387394
Expect(err).NotTo(HaveOccurred(), "while deleting pod")
388395
}
389396

390-
// TestPodSubpath runs pod subpath test
391-
func TestPodSubpath(f *framework.Framework, subpath, volumeType string, source *v1.VolumeSource, privilegedSecurityContext bool) *v1.Pod {
397+
// SubpathTestPod returns a pod spec for subpath tests
398+
func SubpathTestPod(f *framework.Framework, subpath, volumeType string, source *v1.VolumeSource, privilegedSecurityContext bool) *v1.Pod {
392399
var (
393400
suffix = strings.ToLower(fmt.Sprintf("%s-%s", volumeType, rand.String(4)))
394401
gracePeriod = int64(1)
@@ -479,6 +486,38 @@ func TestPodSubpath(f *framework.Framework, subpath, volumeType string, source *
479486
}
480487
}
481488

489+
// volumeFormatPod returns a Pod that does nothing but will cause the plugin to format a filesystem
490+
// on first use
491+
func volumeFormatPod(f *framework.Framework, volumeSource *v1.VolumeSource) *v1.Pod {
492+
return &v1.Pod{
493+
ObjectMeta: metav1.ObjectMeta{
494+
Name: fmt.Sprintf("volume-prep-%s", f.Namespace.Name),
495+
},
496+
Spec: v1.PodSpec{
497+
Containers: []v1.Container{
498+
{
499+
Name: fmt.Sprintf("init-volume-%s", f.Namespace.Name),
500+
Image: imageutils.GetE2EImage(imageutils.BusyBox),
501+
Command: []string{"/bin/sh", "-ec", "echo nothing"},
502+
VolumeMounts: []v1.VolumeMount{
503+
{
504+
Name: volumeName,
505+
MountPath: "/vol",
506+
},
507+
},
508+
},
509+
},
510+
RestartPolicy: v1.RestartPolicyNever,
511+
Volumes: []v1.Volume{
512+
{
513+
Name: volumeName,
514+
VolumeSource: *volumeSource,
515+
},
516+
},
517+
},
518+
}
519+
}
520+
482521
func clearSubpathPodCommands(pod *v1.Pod) {
483522
pod.Spec.InitContainers[0].Command = nil
484523
pod.Spec.Containers[0].Args = nil
@@ -686,38 +725,9 @@ func testSubpathReconstruction(f *framework.Framework, pod *v1.Pod, forceDelete
686725
utils.TestVolumeUnmountsFromDeletedPodWithForceOption(f.ClientSet, f, pod, forceDelete, true)
687726
}
688727

689-
func formatVolume(f *framework.Framework, volumeSource *v1.VolumeSource) {
690-
var err error
691-
// Launch pod to format the volume
692-
pod := &v1.Pod{
693-
ObjectMeta: metav1.ObjectMeta{
694-
Name: fmt.Sprintf("volume-prep-%s", f.Namespace.Name),
695-
},
696-
Spec: v1.PodSpec{
697-
Containers: []v1.Container{
698-
{
699-
Name: fmt.Sprintf("init-volume-%s", f.Namespace.Name),
700-
Image: imageutils.GetE2EImage(imageutils.BusyBox),
701-
Command: []string{"/bin/sh", "-ec", "echo nothing"},
702-
VolumeMounts: []v1.VolumeMount{
703-
{
704-
Name: volumeName,
705-
MountPath: "/vol",
706-
},
707-
},
708-
},
709-
},
710-
RestartPolicy: v1.RestartPolicyNever,
711-
Volumes: []v1.Volume{
712-
{
713-
Name: volumeName,
714-
VolumeSource: *volumeSource,
715-
},
716-
},
717-
},
718-
}
728+
func formatVolume(f *framework.Framework, pod *v1.Pod) {
719729
By(fmt.Sprintf("Creating pod to format volume %s", pod.Name))
720-
pod, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
730+
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(pod)
721731
Expect(err).ToNot(HaveOccurred(), "while creating volume init pod")
722732

723733
err = framework.WaitForPodSuccessInNamespace(f.ClientSet, pod.Name, pod.Namespace)

0 commit comments

Comments
 (0)