From 5c67d5500233a4ca57bae07d9377d538615fce4a Mon Sep 17 00:00:00 2001 From: Yecheng Fu Date: Thu, 21 Feb 2019 15:42:39 +0800 Subject: [PATCH] Use same fsGroup for both pods until we have a reliable way to detect volumes are unmounted or not --- test/e2e/framework/volume_util.go | 7 ++++--- test/e2e/storage/testsuites/volumes.go | 6 +++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/e2e/framework/volume_util.go b/test/e2e/framework/volume_util.go index b5c95741fd..52f6cf4252 100644 --- a/test/e2e/framework/volume_util.go +++ b/test/e2e/framework/volume_util.go @@ -487,7 +487,7 @@ func TestVolumeClient(client clientset.Interface, config VolumeTestConfig, fsGro // Insert index.html with given content into given volume. It does so by // starting and auxiliary pod which writes the file there. // The volume must be writable. -func InjectHtml(client clientset.Interface, config VolumeTestConfig, volume v1.VolumeSource, content string) { +func InjectHtml(client clientset.Interface, config VolumeTestConfig, fsGroup *int64, volume v1.VolumeSource, content string) { By(fmt.Sprint("starting ", config.Prefix, " injector")) podClient := client.CoreV1().Pods(config.Namespace) podName := fmt.Sprintf("%s-injector-%s", config.Prefix, rand.String(4)) @@ -523,6 +523,9 @@ func InjectHtml(client clientset.Interface, config VolumeTestConfig, volume v1.V }, }, }, + SecurityContext: &v1.PodSecurityContext{ + FSGroup: fsGroup, + }, RestartPolicy: v1.RestartPolicyNever, Volumes: []v1.Volume{ { @@ -537,8 +540,6 @@ func InjectHtml(client clientset.Interface, config VolumeTestConfig, volume v1.V defer func() { podClient.Delete(podName, nil) - err := waitForPodNotFoundInNamespace(client, podName, injectPod.Namespace, PodDeleteTimeout) - ExpectNoError(err) }() injectPod, err := podClient.Create(injectPod) diff --git a/test/e2e/storage/testsuites/volumes.go b/test/e2e/storage/testsuites/volumes.go index 3820295dfa..364a1bd501 100644 --- a/test/e2e/storage/testsuites/volumes.go +++ b/test/e2e/storage/testsuites/volumes.go @@ -148,12 +148,16 @@ func (t *volumesTestSuite) defineTests(driver TestDriver, pattern testpatterns.T }, } config := convertTestConfig(l.config) - framework.InjectHtml(f.ClientSet, config, tests[0].Volume, tests[0].ExpectedContent) var fsGroup *int64 if dInfo.Capabilities[CapFsGroup] { fsGroupVal := int64(1234) fsGroup = &fsGroupVal } + // We set same fsGroup for both pods, because for same volumes (e.g. + // local), plugin skips setting fsGroup if volume is already mounted + // and we don't have reliable way to detect volumes are unmounted or + // not before starting the second pod. + framework.InjectHtml(f.ClientSet, config, fsGroup, tests[0].Volume, tests[0].ExpectedContent) framework.TestVolumeClient(f.ClientSet, config, fsGroup, pattern.FsType, tests) })