@@ -95,61 +95,24 @@ func CleanupMountPoint(path string, m *mount.SafeFormatAndMount, unmountVolume b
95
95
}
96
96
97
97
func getDevicePathWithMountPath (mountPath string , m * mount.SafeFormatAndMount ) (string , error ) {
98
- var devicePath string
99
- var err error
100
-
101
98
if proxy , ok := m .Interface .(mounter.CSIProxyMounter ); ok {
102
- devicePath , err = proxy .GetDeviceNameFromMount (mountPath , "" )
103
- } else {
104
- return "" , fmt .Errorf ("could not cast to csi proxy class" )
105
- }
106
-
107
- if err != nil {
108
- if sts , ok := status .FromError (err ); ok {
109
- return "" , fmt .Errorf (sts .Message ())
110
- }
111
- return "" , err
99
+ return proxy .GetDeviceNameFromMount (mountPath , "" )
112
100
}
113
-
114
- return devicePath , nil
101
+ return "" , fmt .Errorf ("could not cast to csi proxy class" )
115
102
}
116
103
117
104
func getBlockSizeBytes (devicePath string , m * mount.SafeFormatAndMount ) (int64 , error ) {
118
- var sizeInBytes int64
119
- var err error
120
-
121
105
if proxy , ok := m .Interface .(mounter.CSIProxyMounter ); ok {
122
- sizeInBytes , err = proxy .GetVolumeSizeInBytes (devicePath )
123
- } else {
124
- return - 1 , fmt .Errorf ("could not cast to csi proxy class" )
125
- }
126
-
127
- if err != nil {
128
- if sts , ok := status .FromError (err ); ok {
129
- return - 1 , fmt .Errorf (sts .Message ())
130
- }
131
- return - 1 , err
106
+ return proxy .GetVolumeSizeInBytes (devicePath )
132
107
}
133
-
134
- return sizeInBytes , nil
108
+ return - 1 , fmt .Errorf ("could not cast to csi proxy class" )
135
109
}
136
110
137
111
func resizeVolume (devicePath , volumePath string , m * mount.SafeFormatAndMount ) error {
138
- var err error
139
112
if proxy , ok := m .Interface .(mounter.CSIProxyMounter ); ok {
140
- err = proxy .ResizeVolume (devicePath )
141
- } else {
142
- return fmt .Errorf ("could not cast to csi proxy class" )
113
+ return proxy .ResizeVolume (devicePath )
143
114
}
144
-
145
- if err != nil {
146
- if sts , ok := status .FromError (err ); ok {
147
- return fmt .Errorf (sts .Message ())
148
- }
149
- return err
150
- }
151
-
152
- return nil
115
+ return fmt .Errorf ("could not cast to csi proxy class" )
153
116
}
154
117
155
118
// needResizeVolume check whether device needs resize
@@ -171,7 +134,7 @@ func (d *DriverCore) GetVolumeStats(ctx context.Context, m *mount.SafeFormatAndM
171
134
// check if the volume stats is cached
172
135
cache , err := d .volStatsCache .Get (ctx , volumeID , azcache .CacheReadTypeDefault )
173
136
if err != nil {
174
- return nil , status .Errorf (codes .Internal , err . Error () )
137
+ return nil , status .Errorf (codes .Internal , "%v" , err )
175
138
}
176
139
if cache != nil {
177
140
volUsage := cache .(csi.VolumeUsage )
0 commit comments