Skip to content

Commit 04c2c93

Browse files
authored
feat(linstor): Add new debug log in linstorhostcall (#67)
Signed-off-by: Damien Thenot <[email protected]>
1 parent 31d150b commit 04c2c93

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

drivers/linstorvhdutil.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ class ErofsLinstorCallException(LinstorCallException):
7878
class NoPathLinstorCallException(LinstorCallException):
7979
pass
8080

81+
def log_successful_call(target_host, device_path, vdi_uuid, remote_method, response):
82+
util.SMlog(
83+
'Successful access on {} for device {} ({}): `{}` => {}'.format(target_host, device_path, vdi_uuid, remote_method, str(response)),
84+
priority=util.LOG_DEBUG
85+
)
86+
87+
def log_failed_call(target_host, next_target, device_path, vdi_uuid, remote_method, e):
88+
util.SMlog(
89+
'Failed to call method on {} for device {} ({}): {}. Trying accessing on {}... (cause: {})'.format(target_host, device_path, vdi_uuid, remote_method, next_target, e),
90+
priority=util.LOG_DEBUG
91+
)
8192

8293
def linstorhostcall(local_method, remote_method):
8394
def decorated(response_parser):
@@ -102,39 +113,36 @@ def wrapper(*args, **kwargs):
102113
response = call_remote_method(
103114
self._session, host_ref_attached, remote_method, device_path, remote_args
104115
)
116+
log_successful_call('attached node', device_path, vdi_uuid, remote_method, response)
105117
return response_parser(self, vdi_uuid, response)
106118
except Exception as e:
107-
util.SMlog(
108-
'Failed to call method on attached host. Trying local access... (cause: {})'.format(e),
109-
priority=util.LOG_DEBUG
110-
)
119+
log_failed_call('attached node', 'master', device_path, vdi_uuid, remote_method, e)
111120

112121
try:
113122
master_ref = self._session.xenapi.pool.get_all_records().values()[0]['master']
114123
response = call_remote_method(self._session, master_ref, remote_method, device_path, remote_args)
124+
log_successful_call('master', device_path, vdi_uuid, remote_method, response)
115125
return response_parser(self, vdi_uuid, response)
116126
except Exception as e:
117-
util.SMlog(
118-
'Failed to call method on master host. Finding primary node... (cause: {})'.format(e),
119-
priority=util.LOG_DEBUG
120-
)
127+
log_failed_call('master', 'primary', device_path, vdi_uuid, remote_method, e)
128+
121129

122130
nodes, primary_hostname = self._linstor.find_up_to_date_diskful_nodes(vdi_uuid)
123131
if primary_hostname:
124132
try:
125133
host_ref = self._get_readonly_host(vdi_uuid, device_path, {primary_hostname})
126134
response = call_remote_method(self._session, host_ref, remote_method, device_path, remote_args)
135+
log_successful_call('primary', device_path, vdi_uuid, remote_method, response)
127136
return response_parser(self, vdi_uuid, response)
128137
except Exception as remote_e:
129138
self._raise_openers_exception(device_path, remote_e)
130139
else:
131-
util.SMlog(
132-
'Couldn\'t get primary for {}. Trying with another node...'.format(vdi_uuid),
133-
priority=util.LOG_DEBUG
134-
)
140+
log_failed_call('primary', 'another node', device_path, vdi_uuid, remote_method, e)
141+
135142
try:
136143
host = self._get_readonly_host(vdi_uuid, device_path, nodes)
137144
response = call_remote_method(self._session, host, remote_method, device_path, remote_args)
145+
log_successful_call('another node', device_path, vdi_uuid, remote_method, response)
138146
return response_parser(self, vdi_uuid, response)
139147
except Exception as remote_e:
140148
self._raise_openers_exception(device_path, remote_e)

0 commit comments

Comments
 (0)