@@ -182,11 +182,13 @@ func (m *mounter) getDevicePathForVMware(ctx context.Context, volumeID string) (
182182 if err == nil && isBlock {
183183 if m .verifyDevice (ctx , devicePath , volumeID ) {
184184 logger .V (4 ).Info ("Found and verified VMware device" , "devicePath" , devicePath , "volumeID" , volumeID )
185+
185186 return devicePath , nil
186187 }
187188 }
188189 }
189190 }
191+
190192 return "" , fmt .Errorf ("device not found for volume %s" , volumeID )
191193}
192194
@@ -196,23 +198,27 @@ func (m *mounter) verifyDevice(ctx context.Context, devicePath string, volumeID
196198 size , err := m .GetBlockSizeBytes (devicePath )
197199 if err != nil {
198200 logger .V (4 ).Info ("Failed to get device size" , "devicePath" , devicePath , "volumeID" , volumeID , "error" , err )
201+
199202 return false
200203 }
201204 logger .V (5 ).Info ("Device size retrieved" , "devicePath" , devicePath , "volumeID" , volumeID , "sizeBytes" , size )
202205
203206 mounted , err := m .isDeviceMounted (devicePath )
204207 if err != nil {
205208 logger .V (4 ).Info ("Failed to check if device is mounted" , "devicePath" , devicePath , "volumeID" , volumeID , "error" , err )
209+
206210 return false
207211 }
208212 if mounted {
209213 logger .V (4 ).Info ("Device is already mounted" , "devicePath" , devicePath , "volumeID" , volumeID )
214+
210215 return false
211216 }
212217
213218 props , err := m .getDeviceProperties (devicePath )
214219 if err != nil {
215220 logger .V (4 ).Info ("Failed to get device properties" , "devicePath" , devicePath , "volumeID" , volumeID , "error" , err )
221+
216222 return false
217223 }
218224 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) {
226232 if strings .Contains (err .Error (), "exit status 1" ) {
227233 return false , nil
228234 }
235+
229236 return false , err
230237 }
238+
231239 return len (output ) > 0 , nil
232240}
233241
0 commit comments