Skip to content

Commit b55072d

Browse files
authored
fix(linstorvhdutil): retry check on another machine in case of failure (#54)
Signed-off-by: Ronan Abhamon <[email protected]>
1 parent f36a7a2 commit b55072d

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

drivers/linstor-manager

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import XenAPIPlugin
2929

3030
from json import JSONEncoder
3131
from linstorjournaler import LinstorJournaler
32-
from linstorvhdutil import LinstorVhdUtil
32+
from linstorvhdutil import LinstorVhdUtil, check_ex
3333
from linstorvolumemanager import get_controller_uri, get_local_volume_openers, LinstorVolumeManager
3434
from lock import Lock
3535
import json
@@ -390,7 +390,8 @@ def check(session, args):
390390
args['ignoreMissingFooter']
391391
)
392392
fast = distutils.util.strtobool(args['fast'])
393-
return str(vhdutil.check(device_path, ignore_missing_footer, fast))
393+
check_ex(device_path, ignore_missing_footer, fast)
394+
return str(True)
394395
except Exception as e:
395396
util.SMlog('linstor-manager:check error: {}'.format(e))
396397
raise

drivers/linstorvhdutil.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ def call_remote_method(session, host_ref, method, device_path, args):
5050
return response
5151

5252

53+
def check_ex(path, ignoreMissingFooter = False, fast = False):
54+
cmd = [vhdutil.VHD_UTIL, "check", vhdutil.OPT_LOG_ERR, "-n", path]
55+
if ignoreMissingFooter:
56+
cmd.append("-i")
57+
if fast:
58+
cmd.append("-B")
59+
60+
vhdutil.ioretry(cmd)
61+
62+
5363
class LinstorCallException(util.SMException):
5464
def __init__(self, cmd_err):
5565
self.cmd_err = cmd_err
@@ -188,9 +198,14 @@ def check(self, vdi_uuid, ignore_missing_footer=False, fast=False):
188198
'ignoreMissingFooter': ignore_missing_footer,
189199
'fast': fast
190200
}
191-
return self._check(vdi_uuid, **kwargs) # pylint: disable = E1123
201+
try:
202+
self._check(vdi_uuid, **kwargs) # pylint: disable = E1123
203+
return True
204+
except Exception as e:
205+
util.SMlog('Call to `check` failed: {}'.format(e))
206+
return False
192207

193-
@linstorhostcall(vhdutil.check, 'check')
208+
@linstorhostcall(check_ex, 'check')
194209
def _check(self, vdi_uuid, response):
195210
return distutils.util.strtobool(response)
196211

0 commit comments

Comments
 (0)