@@ -182,11 +182,13 @@ func (m *mounter) getDevicePathForVMware(ctx context.Context, volumeID string) (
182
182
if err == nil && isBlock {
183
183
if m .verifyDevice (ctx , devicePath , volumeID ) {
184
184
logger .V (4 ).Info ("Found and verified VMware device" , "devicePath" , devicePath , "volumeID" , volumeID )
185
+
185
186
return devicePath , nil
186
187
}
187
188
}
188
189
}
189
190
}
191
+
190
192
return "" , fmt .Errorf ("device not found for volume %s" , volumeID )
191
193
}
192
194
@@ -196,23 +198,27 @@ func (m *mounter) verifyDevice(ctx context.Context, devicePath string, volumeID
196
198
size , err := m .GetBlockSizeBytes (devicePath )
197
199
if err != nil {
198
200
logger .V (4 ).Info ("Failed to get device size" , "devicePath" , devicePath , "volumeID" , volumeID , "error" , err )
201
+
199
202
return false
200
203
}
201
204
logger .V (5 ).Info ("Device size retrieved" , "devicePath" , devicePath , "volumeID" , volumeID , "sizeBytes" , size )
202
205
203
206
mounted , err := m .isDeviceMounted (devicePath )
204
207
if err != nil {
205
208
logger .V (4 ).Info ("Failed to check if device is mounted" , "devicePath" , devicePath , "volumeID" , volumeID , "error" , err )
209
+
206
210
return false
207
211
}
208
212
if mounted {
209
213
logger .V (4 ).Info ("Device is already mounted" , "devicePath" , devicePath , "volumeID" , volumeID )
214
+
210
215
return false
211
216
}
212
217
213
218
props , err := m .getDeviceProperties (devicePath )
214
219
if err != nil {
215
220
logger .V (4 ).Info ("Failed to get device properties" , "devicePath" , devicePath , "volumeID" , volumeID , "error" , err )
221
+
216
222
return false
217
223
}
218
224
logger .V (5 ).Info ("Device properties retrieved" , "devicePath" , devicePath , "volumeID" , volumeID , "properties" , props )
@@ -226,8 +232,10 @@ func (m *mounter) isDeviceMounted(devicePath string) (bool, error) {
226
232
if strings .Contains (err .Error (), "exit status 1" ) {
227
233
return false , nil
228
234
}
235
+
229
236
return false , err
230
237
}
238
+
231
239
return len (output ) > 0 , nil
232
240
}
233
241
0 commit comments