...
1
16
17 package flexvolume
18
19 import (
20 "fmt"
21 "strconv"
22
23 "k8s.io/apimachinery/pkg/api/resource"
24 "k8s.io/kubernetes/pkg/volume"
25 )
26
27 func (plugin *flexVolumePlugin) ExpandVolumeDevice(spec *volume.Spec, newSize resource.Quantity, oldSize resource.Quantity) (resource.Quantity, error) {
28 call := plugin.NewDriverCall(expandVolumeCmd)
29 call.AppendSpec(spec, plugin.host, nil)
30
31 devicePath, err := plugin.getDeviceMountPath(spec)
32 if err != nil {
33 return newSize, err
34 }
35 call.Append(devicePath)
36 call.Append(strconv.FormatInt(newSize.Value(), 10))
37 call.Append(strconv.FormatInt(oldSize.Value(), 10))
38
39 _, err = call.Run()
40 if isCmdNotSupportedErr(err) {
41 return newExpanderDefaults(plugin).ExpandVolumeDevice(spec, newSize, oldSize)
42 }
43 return newSize, err
44 }
45
46 func (plugin *flexVolumePlugin) NodeExpand(rsOpt volume.NodeResizeOptions) (bool, error) {
47
48
49
50
51
52 if rsOpt.VolumeSpec.PersistentVolume == nil {
53 return false, fmt.Errorf("PersistentVolume not found for spec: %s", rsOpt.VolumeSpec.Name())
54 }
55
56 call := plugin.NewDriverCall(expandFSCmd)
57 call.AppendSpec(rsOpt.VolumeSpec, plugin.host, nil)
58 call.Append(rsOpt.DevicePath)
59 call.Append(rsOpt.DeviceMountPath)
60 call.Append(strconv.FormatInt(rsOpt.NewSize.Value(), 10))
61 call.Append(strconv.FormatInt(rsOpt.OldSize.Value(), 10))
62
63 _, err := call.Run()
64 if isCmdNotSupportedErr(err) {
65 return newExpanderDefaults(plugin).NodeExpand(rsOpt)
66 }
67 if err != nil {
68 return false, err
69 }
70 return true, nil
71 }
72
View as plain text