mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-23 14:50:24 +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>
(cherry picked from commit b4e6504e9b
)
This commit is contained in:
parent
8e870fd858
commit
90f62308f2
@ -326,6 +326,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
|
// Make sure this should be last testcase in this file, because
|
||||||
// it deletes pool
|
// it deletes pool
|
||||||
By("Create a PVC and Delete PVC when backend pool deleted", func() {
|
By("Create a PVC and Delete PVC when backend pool deleted", func() {
|
||||||
|
37
e2e/utils.go
37
e2e/utils.go
@ -943,3 +943,40 @@ func pvcDeleteWhenPoolNotFound(pvcPath string, cephfs bool, f *framework.Framewo
|
|||||||
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
||||||
return err
|
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
|
||||||
|
}
|
||||||
|
@ -332,6 +332,7 @@ func (ns *NodeServer) mountVolumeToStagePath(ctx context.Context, req *csi.NodeS
|
|||||||
}
|
}
|
||||||
|
|
||||||
opt := []string{"_netdev"}
|
opt := []string{"_netdev"}
|
||||||
|
opt = csicommon.ConstructMountOptions(opt, req.GetVolumeCapability())
|
||||||
isBlock := req.GetVolumeCapability().GetBlock() != nil
|
isBlock := req.GetVolumeCapability().GetBlock() != nil
|
||||||
|
|
||||||
if isBlock {
|
if isBlock {
|
||||||
|
Loading…
Reference in New Issue
Block a user