...
1
16
17 package flexvolume
18
19 import (
20 "time"
21
22 "k8s.io/klog/v2"
23 "k8s.io/mount-utils"
24
25 "k8s.io/apimachinery/pkg/types"
26 "k8s.io/kubernetes/pkg/volume"
27 )
28
29 type attacherDefaults flexVolumeAttacher
30
31
32 func (a *attacherDefaults) Attach(spec *volume.Spec, hostName types.NodeName) (string, error) {
33 klog.Warning(logPrefix(a.plugin.flexVolumePlugin), "using default Attach for volume ", spec.Name(), ", host ", hostName)
34 return "", nil
35 }
36
37
38 func (a *attacherDefaults) WaitForAttach(spec *volume.Spec, devicePath string, timeout time.Duration) (string, error) {
39 klog.Warning(logPrefix(a.plugin.flexVolumePlugin), "using default WaitForAttach for volume ", spec.Name(), ", device ", devicePath)
40 return devicePath, nil
41 }
42
43
44 func (a *attacherDefaults) GetDeviceMountPath(spec *volume.Spec, mountsDir string) (string, error) {
45 return a.plugin.getDeviceMountPath(spec)
46 }
47
48
49 func (a *attacherDefaults) MountDevice(spec *volume.Spec, devicePath string, deviceMountPath string, mounter mount.Interface) error {
50 klog.Warning(logPrefix(a.plugin.flexVolumePlugin), "using default MountDevice for volume ", spec.Name(), ", device ", devicePath, ", deviceMountPath ", deviceMountPath)
51
52 volSourceFSType, err := getFSType(spec)
53 if err != nil {
54 return err
55 }
56
57 readOnly, err := getReadOnly(spec)
58 if err != nil {
59 return err
60 }
61
62 options := make([]string, 0)
63
64 if readOnly {
65 options = append(options, "ro")
66 } else {
67 options = append(options, "rw")
68 }
69
70 diskMounter := &mount.SafeFormatAndMount{Interface: mounter, Exec: a.plugin.host.GetExec(a.plugin.GetPluginName())}
71
72 return diskMounter.FormatAndMount(devicePath, deviceMountPath, volSourceFSType, options)
73 }
74
View as plain text