mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
Fix mountoption issue in rbd
use mountoptions when mounting rbd to stagingpath in stagevolume request, add E2E for mount options fixes: #846 updates: #757 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
40d0d5d291
commit
b4e6504e9b
@ -393,6 +393,14 @@ var _ = Describe("RBD", func() {
|
||||
}
|
||||
})
|
||||
|
||||
By("validate mount options in app pod", func() {
|
||||
mountFlags := []string{"discard"}
|
||||
err := checkMountOptions(pvcPath, appPath, f, mountFlags)
|
||||
if err != nil {
|
||||
Fail(err.Error())
|
||||
}
|
||||
})
|
||||
|
||||
// Make sure this should be last testcase in this file, because
|
||||
// it deletes pool
|
||||
By("Create a PVC and Delete PVC when backend pool deleted", func() {
|
||||
|
37
e2e/utils.go
37
e2e/utils.go
@ -992,3 +992,40 @@ func pvcDeleteWhenPoolNotFound(pvcPath string, cephfs bool, f *framework.Framewo
|
||||
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
||||
return err
|
||||
}
|
||||
|
||||
func checkMountOptions(pvcPath, appPath string, f *framework.Framework, mountFlags []string) error {
|
||||
pvc, err := loadPVC(pvcPath)
|
||||
if pvc == nil {
|
||||
return err
|
||||
}
|
||||
|
||||
pvc.Namespace = f.UniqueName
|
||||
|
||||
app, err := loadApp(appPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
app.Labels = map[string]string{"app": "validate-mount-opt"}
|
||||
app.Namespace = f.UniqueName
|
||||
|
||||
err = createPVCAndApp("", f, pvc, app)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
opt := metav1.ListOptions{
|
||||
LabelSelector: "app=validate-mount-opt",
|
||||
}
|
||||
|
||||
cmd := fmt.Sprintf("mount |grep %s", app.Spec.Containers[0].VolumeMounts[0].MountPath)
|
||||
data, stdErr := execCommandInPod(f, cmd, app.Namespace, &opt)
|
||||
Expect(stdErr).Should(BeEmpty())
|
||||
for _, f := range mountFlags {
|
||||
if !strings.Contains(data, f) {
|
||||
return fmt.Errorf("mount option %s not found in %s", f, data)
|
||||
}
|
||||
}
|
||||
|
||||
err = deletePVCAndApp("", f, pvc, app)
|
||||
return err
|
||||
}
|
||||
|
@ -399,6 +399,7 @@ func (ns *NodeServer) mountVolumeToStagePath(ctx context.Context, req *csi.NodeS
|
||||
}
|
||||
|
||||
opt := []string{"_netdev"}
|
||||
opt = csicommon.ConstructMountOptions(opt, req.GetVolumeCapability())
|
||||
isBlock := req.GetVolumeCapability().GetBlock() != nil
|
||||
|
||||
if isBlock {
|
||||
|
Loading…
Reference in New Issue
Block a user