Skip to content

Commit cc65220

Browse files
committed
Merge pull request oracle#384 in OKE/oci-cloud-controller-manager from task/OKE-22636-1.24 to release-1.24
* commit 'c4224b27b8abcfab56599b4fc60bcaad4e7c5239': JIRA:task/OKE-22216 Add mount option support to FSS CSI driver
2 parents d4f6dc1 + c4224b2 commit cc65220

File tree

6 files changed

+88
-24
lines changed

6 files changed

+88
-24
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ RUN yum-config-manager --disable \* && yum-config-manager --add-repo https://art
1717

1818
RUN yum install -y util-linux \
1919
&& yum install -y e2fsprogs \
20+
&& yum install -y xfsprogs \
2021
&& yum clean all
2122

2223
COPY --from=0 /go/src/github.com/oracle/oci-cloud-controller-manager/dist/* /usr/local/bin/

Dockerfile_arm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ RUN yum-config-manager --disable \* && yum-config-manager --add-repo https://art
1818

1919
RUN yum install -y util-linux \
2020
&& yum install -y e2fsprogs \
21+
&& yum install -y xfsprogs \
2122
&& yum clean all
2223

2324
COPY --from=0 /go/src/github.com/oracle/oci-cloud-controller-manager/dist/arm/oci-csi-node-driver /usr/local/bin/

pkg/csi/driver/fss_node.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ func (d FSSNodeDriver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVo
4646
var fsType = ""
4747

4848
accessType := req.VolumeCapability.GetMount()
49-
50-
if accessType != nil && accessType.FsType != "" {
51-
fsType = accessType.FsType
49+
var options []string
50+
if accessType != nil {
51+
if accessType.MountFlags != nil {
52+
options = accessType.MountFlags
53+
}
54+
if accessType.FsType != "" {
55+
fsType = accessType.FsType
56+
}
5257
}
5358
encryptInTransit, err := isInTransitEncryptionEnabled(req.VolumeContext)
5459
if err != nil {
@@ -57,7 +62,6 @@ func (d FSSNodeDriver) NodeStageVolume(ctx context.Context, req *csi.NodeStageVo
5762

5863
mounter := mount.New(mountPath)
5964

60-
var options []string
6165
if encryptInTransit {
6266
isPackageInstalled, err := csi_util.IsInTransitEncryptionPackageInstalled()
6367
if err != nil {

test/e2e/cloud-provider-oci/fss.go renamed to test/e2e/cloud-provider-oci/fss_static.go

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,47 +21,70 @@ import (
2121
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
)
2323

24-
var _ = Describe("Basic FSS test", func() {
24+
var _ = Describe("Basic Static FSS test", func() {
2525
f := framework.NewDefaultFramework("fss-basic")
26-
Context("[cloudprovider][storage][csi][fss]", func() {
26+
Context("[cloudprovider][storage][csi][fss][static]", func() {
2727
It("Create PVC and POD for CSI-FSS", func() {
2828
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-fss-e2e-test")
29-
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "false")
29+
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "false", []string{})
3030
pvc := pvcJig.CreateAndAwaitPVCOrFailFSS(f.Namespace.Name, pv.Name, "50Gi", nil)
3131
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
32-
pvcJig.CheckSinglePodReadWrite(f.Namespace.Name, pvc.Name, false)
32+
pvcJig.CheckSinglePodReadWrite(f.Namespace.Name, pvc.Name, false, []string{})
3333
})
3434
})
3535
})
3636

37-
var _ = Describe("FSS in-transit encryption test", func() {
37+
var _ = Describe("FSS Static in-transit encryption test", func() {
3838
f := framework.NewDefaultFramework("fss-basic")
39-
Context("[cloudprovider][storage][csi][fss]", func() {
39+
Context("[cloudprovider][storage][csi][fss][static]", func() {
4040
It("Create PVC and POD for FSS in-transit encryption", func() {
4141
if setupF.Architecture == "AMD" {
4242
checkNodeAvailability(f)
43-
TestEncryptionType(f)
43+
TestEncryptionType(f, []string{})
4444
} else {
4545
framework.Logf("CSI-FSS Intransit Encryption is not supported on ARM architecture")
4646
}
4747
})
4848
})
4949
})
5050

51-
func TestEncryptionType(f *framework.CloudProviderFramework) {
51+
var _ = Describe("Mount Options Static FSS test", func() {
52+
f := framework.NewDefaultFramework("fss-mnt-opt")
53+
Context("[cloudprovider][storage][csi][fss][static]", func() {
54+
It("Create PV PVC and POD for CSI-FSS with mount options", func() {
55+
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-fss-e2e-test")
56+
mountOptions := []string{"sync", "hard", "noac", "nolock"}
57+
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "false", mountOptions)
58+
pvc := pvcJig.CreateAndAwaitPVCOrFailFSS(f.Namespace.Name, pv.Name, "50Gi", nil)
59+
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
60+
pvcJig.CheckSinglePodReadWrite(f.Namespace.Name, pvc.Name, false, mountOptions)
61+
})
62+
// TODO : Uncomment the below test once https://jira-sd.mc1.oracleiaas.com/browse/FSS-132761 is Done.
63+
/*It("Create PV PVC and POD for FSS in-transit encryption with mount options", func() {
64+
if setupF.Architecture == "AMD" {
65+
checkNodeAvailability(f)
66+
TestEncryptionType(f, []string{"sync", "hard", "noac", "nolock"})
67+
} else {
68+
framework.Logf("CSI-FSS Intransit Encryption is not supported on ARM architecture")
69+
}
70+
})*/
71+
})
72+
})
73+
74+
func TestEncryptionType(f *framework.CloudProviderFramework, mountOptions []string) {
5275
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-fss-e2e-test-intransit")
53-
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "true")
76+
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "true", mountOptions)
5477
pvc := pvcJig.CreateAndAwaitPVCOrFailFSS(f.Namespace.Name, pv.Name, "50Gi", nil)
5578
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
56-
pvcJig.CheckSinglePodReadWrite(f.Namespace.Name, pvc.Name, true)
79+
pvcJig.CheckSinglePodReadWrite(f.Namespace.Name, pvc.Name, true, mountOptions)
5780
}
5881

59-
var _ = Describe("Multiple Pods FSS test", func() {
82+
var _ = Describe("Multiple Pods Static FSS test", func() {
6083
f := framework.NewDefaultFramework("multiple-pod")
61-
Context("[cloudprovider][storage][csi][fss]", func() {
84+
Context("[cloudprovider][storage][csi][fss][static]", func() {
6285
It("Multiple Pods should be able to read write same file", func() {
6386
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-fss-e2e-test")
64-
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "false")
87+
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "false", []string{})
6588
pvc := pvcJig.CreateAndAwaitPVCOrFailFSS(f.Namespace.Name, pv.Name, "50Gi", nil)
6689
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
6790
pvcJig.CheckMultiplePodReadWrite(f.Namespace.Name, pvc.Name, false)
@@ -71,7 +94,7 @@ var _ = Describe("Multiple Pods FSS test", func() {
7194
if setupF.Architecture == "AMD" {
7295
checkNodeAvailability(f)
7396
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-fss-e2e-test")
74-
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "true")
97+
pv := pvcJig.CreatePVorFailFSS(f.Namespace.Name, setupF.VolumeHandle, "true", []string{})
7598
pvc := pvcJig.CreateAndAwaitPVCOrFailFSS(f.Namespace.Name, pv.Name, "50Gi", nil)
7699
f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
77100
pvcJig.CheckMultiplePodReadWrite(f.Namespace.Name, pvc.Name, true)
@@ -82,9 +105,9 @@ var _ = Describe("Multiple Pods FSS test", func() {
82105
})
83106
})
84107

85-
func checkNodeAvailability(f *framework.CloudProviderFramework){
108+
func checkNodeAvailability(f *framework.CloudProviderFramework) {
86109
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-fss-e2e-test")
87-
nodeList, err := pvcJig.KubeClient.CoreV1().Nodes().List(context.Background(),v12.ListOptions{LabelSelector: "oke.oraclecloud.com/e2e.oci-fss-util"})
110+
nodeList, err := pvcJig.KubeClient.CoreV1().Nodes().List(context.Background(), v12.ListOptions{LabelSelector: "oke.oraclecloud.com/e2e.oci-fss-util"})
88111
if err != nil {
89112
framework.Logf("Error getting applicable nodes: %v", err)
90113
}

test/e2e/framework/pod_util.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,29 @@ func (j *PVCTestJig) CheckFileExists(namespace string, podName string, dir strin
8888
}
8989
}
9090

91+
func (j *PVCTestJig) CheckMountOptions(namespace string, podName string, expectedPath string, expectedOptions []string) {
92+
By("check if NFS mount options are applied")
93+
command := fmt.Sprintf("mount -t nfs")
94+
if pollErr := wait.PollImmediate(K8sResourcePoll, DefaultTimeout, func() (bool, error) {
95+
stdout, err := RunHostCmd(namespace, podName, command)
96+
if err != nil {
97+
Logf("got err: %v, retry until timeout", err)
98+
return false, nil
99+
}
100+
if stdout == "" || !strings.Contains(stdout, expectedPath) {
101+
return false, errors.Errorf("NFS Mount not found for path %s. Mounted as %s", expectedPath, stdout)
102+
}
103+
for _, option := range expectedOptions {
104+
if !strings.Contains(stdout, option) {
105+
return false, errors.Errorf("NFS Mount Options check failed. Mounted as %s", stdout)
106+
}
107+
}
108+
return true, nil
109+
}); pollErr != nil {
110+
Failf("NFS mount with Mount Options failed in pod '%v'", podName)
111+
}
112+
}
113+
91114
func (j *PVCTestJig) CheckFileCorruption(namespace string, podName string, dir string, fileName string) {
92115
By("check if the file is corrupt")
93116
md5hash := "e59ff97941044f85df5297e1c302d260"

test/e2e/framework/pvc_util.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,22 @@ func (j *PVCTestJig) pvAddPersistentVolumeSource(pv *v1.PersistentVolume,
377377
return pv
378378
}
379379

380+
func (j *PVCTestJig) pvAddMountOptions(pv *v1.PersistentVolume,
381+
mountOptions []string) *v1.PersistentVolume {
382+
if pv != nil {
383+
pv.Spec.MountOptions = append(pv.Spec.MountOptions, mountOptions...)
384+
}
385+
return pv
386+
}
387+
380388
// newPVTemplateFSS returns the default template for this jig, but
381389
// does not actually create the PV. The default PV has the same name
382390
// as the jig
383-
func (j *PVCTestJig) newPVTemplateFSS(namespace, volumeHandle, enableIntransitEncrypt string) *v1.PersistentVolume {
391+
func (j *PVCTestJig) newPVTemplateFSS(namespace, volumeHandle, enableIntransitEncrypt string, mountOptions []string) *v1.PersistentVolume {
384392
pv := j.CreatePVTemplate(namespace, "fss.csi.oraclecloud.com", "", "Retain")
385393
pv = j.pvAddVolumeMode(pv, v1.PersistentVolumeFilesystem)
386394
pv = j.pvAddAccessMode(pv, "ReadWriteMany")
395+
pv = j.pvAddMountOptions(pv, mountOptions)
387396
pv = j.pvAddPersistentVolumeSource(pv, v1.PersistentVolumeSource{
388397
CSI: &v1.CSIPersistentVolumeSource{
389398
Driver: driver.FSSDriverName,
@@ -435,8 +444,8 @@ func (j *PVCTestJig) newPVTemplateCSIHighPerf(namespace string, scName string, o
435444
// CreatePVForFSSorFail creates a new claim based on the jig's
436445
// defaults. Callers can provide a function to tweak the claim object
437446
// before it is created.
438-
func (j *PVCTestJig) CreatePVorFailFSS(namespace, volumeHandle, encryptInTransit string) *v1.PersistentVolume {
439-
pv := j.newPVTemplateFSS(namespace, volumeHandle, encryptInTransit)
447+
func (j *PVCTestJig) CreatePVorFailFSS(namespace, volumeHandle, encryptInTransit string, mountOptions []string) *v1.PersistentVolume {
448+
pv := j.newPVTemplateFSS(namespace, volumeHandle, encryptInTransit, mountOptions)
440449

441450
result, err := j.KubeClient.CoreV1().PersistentVolumes().Create(context.Background(), pv, metav1.CreateOptions{})
442451
if err != nil {
@@ -979,7 +988,7 @@ func (j *PVCTestJig) CheckEncryptionType(namespace, podName string) {
979988
}
980989
}
981990

982-
func (j *PVCTestJig) CheckSinglePodReadWrite(namespace string, pvcName string, checkEncryption bool) {
991+
func (j *PVCTestJig) CheckSinglePodReadWrite(namespace string, pvcName string, checkEncryption bool, expectedMountOptions []string) {
983992

984993
By("Creating Pod that can create and write to the file")
985994
uid := uuid.NewUUID()
@@ -995,6 +1004,9 @@ func (j *PVCTestJig) CheckSinglePodReadWrite(namespace string, pvcName string, c
9951004
By("check if the file exists")
9961005
j.CheckFileExists(namespace, podName, "/data", fileName)
9971006

1007+
By("Check Mount Options")
1008+
j.CheckMountOptions(namespace, podName, "/data", expectedMountOptions)
1009+
9981010
By("Creating Pod that can read contents of existing file")
9991011
j.NewPodForCSIFSSRead(string(uid), namespace, pvcName, fileName, checkEncryption)
10001012
}

0 commit comments

Comments
 (0)