Skip to content

Commit ec1d83b

Browse files
authored
Merge pull request kubernetes#74335 from cofyc/fix74229
Use same fsGroup for both pods
2 parents 9b87046 + 5c67d55 commit ec1d83b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

test/e2e/framework/volume_util.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func TestVolumeClient(client clientset.Interface, config VolumeTestConfig, fsGro
487487
// Insert index.html with given content into given volume. It does so by
488488
// starting and auxiliary pod which writes the file there.
489489
// The volume must be writable.
490-
func InjectHtml(client clientset.Interface, config VolumeTestConfig, volume v1.VolumeSource, content string) {
490+
func InjectHtml(client clientset.Interface, config VolumeTestConfig, fsGroup *int64, volume v1.VolumeSource, content string) {
491491
By(fmt.Sprint("starting ", config.Prefix, " injector"))
492492
podClient := client.CoreV1().Pods(config.Namespace)
493493
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
523523
},
524524
},
525525
},
526+
SecurityContext: &v1.PodSecurityContext{
527+
FSGroup: fsGroup,
528+
},
526529
RestartPolicy: v1.RestartPolicyNever,
527530
Volumes: []v1.Volume{
528531
{
@@ -537,8 +540,6 @@ func InjectHtml(client clientset.Interface, config VolumeTestConfig, volume v1.V
537540

538541
defer func() {
539542
podClient.Delete(podName, nil)
540-
err := waitForPodNotFoundInNamespace(client, podName, injectPod.Namespace, PodDeleteTimeout)
541-
ExpectNoError(err)
542543
}()
543544

544545
injectPod, err := podClient.Create(injectPod)

test/e2e/storage/testsuites/volumes.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,16 @@ func (t *volumesTestSuite) defineTests(driver TestDriver, pattern testpatterns.T
148148
},
149149
}
150150
config := convertTestConfig(l.config)
151-
framework.InjectHtml(f.ClientSet, config, tests[0].Volume, tests[0].ExpectedContent)
152151
var fsGroup *int64
153152
if dInfo.Capabilities[CapFsGroup] {
154153
fsGroupVal := int64(1234)
155154
fsGroup = &fsGroupVal
156155
}
156+
// We set same fsGroup for both pods, because for same volumes (e.g.
157+
// local), plugin skips setting fsGroup if volume is already mounted
158+
// and we don't have reliable way to detect volumes are unmounted or
159+
// not before starting the second pod.
160+
framework.InjectHtml(f.ClientSet, config, fsGroup, tests[0].Volume, tests[0].ExpectedContent)
157161
framework.TestVolumeClient(f.ClientSet, config, fsGroup, pattern.FsType, tests)
158162
})
159163

0 commit comments

Comments
 (0)