Skip OnRootMismatch tests if the CSI driver supports VOLUME_MOUNT_GROUP.

This commit is contained in:
Cheng Xing 2021-11-10 15:16:17 -08:00
parent 0c6f1b4e2a
commit 4836fd1510
2 changed files with 12 additions and 2 deletions

View File

@ -151,6 +151,7 @@ const (
CapPersistence Capability = "persistence" // data is persisted across pod restarts
CapBlock Capability = "block" // raw block mode
CapFsGroup Capability = "fsGroup" // volume ownership via fsGroup
CapVolumeMountGroup Capability = "volumeMountGroup" // Driver has the VolumeMountGroup CSI node capability. Because this is a FSGroup feature, the fsGroup capability must also be set to true.
CapExec Capability = "exec" // exec a file in the volume
CapSnapshotDataSource Capability = "snapshotDataSource" // support populate data from snapshot
CapPVCDataSource Capability = "pvcDataSource" // support populate data from pvc

View File

@ -23,6 +23,8 @@ import (
"github.com/onsi/ginkgo"
v1 "k8s.io/api/core/v1"
errors "k8s.io/apimachinery/pkg/util/errors"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
"k8s.io/kubernetes/test/e2e/framework"
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
e2eskipper "k8s.io/kubernetes/test/e2e/framework/skipper"
@ -206,10 +208,17 @@ func (s *fsGroupChangePolicyTestSuite) DefineTests(driver storageframework.TestD
test := t
testCaseName := fmt.Sprintf("(%s)[LinuxOnly], %s", test.podfsGroupChangePolicy, test.name)
ginkgo.It(testCaseName, func() {
dInfo := driver.GetDriverInfo()
policy := v1.PodFSGroupChangePolicy(test.podfsGroupChangePolicy)
if dInfo.Capabilities[storageframework.CapVolumeMountGroup] &&
utilfeature.DefaultFeatureGate.Enabled(features.DelegateFSGroupToCSIDriver) &&
policy == v1.FSGroupChangeOnRootMismatch {
e2eskipper.Skipf("Driver %q supports VolumeMountGroup, which doesn't supported the OnRootMismatch FSGroup policy - skipping", dInfo.Name)
}
init()
defer cleanup()
policy := v1.PodFSGroupChangePolicy(test.podfsGroupChangePolicy)
podConfig := e2epod.Config{
NS: f.Namespace.Name,
NodeSelection: l.config.ClientNodeSelection,