Skip to content

Commit 9ef1c17

Browse files
NambrokWescoeur
authored andcommitted
feat(linstor): Add new debug log in linstorhostcall (#67)
Signed-off-by: Damien Thenot <[email protected]>
1 parent 114c78b commit 9ef1c17

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
@@ -77,6 +77,17 @@ class ErofsLinstorCallException(LinstorCallException):
7777
class NoPathLinstorCallException(LinstorCallException):
7878
pass
7979

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

8192
def linstorhostcall(local_method, remote_method):
8293
def decorated(response_parser):
@@ -101,39 +112,36 @@ def wrapper(*args, **kwargs):
101112
response = call_remote_method(
102113
self._session, host_ref_attached, remote_method, device_path, remote_args
103114
)
115+
log_successful_call('attached node', device_path, vdi_uuid, remote_method, response)
104116
return response_parser(self, vdi_uuid, response)
105117
except Exception as e:
106-
util.SMlog(
107-
'Failed to call method on attached host. Trying local access... (cause: {})'.format(e),
108-
priority=util.LOG_DEBUG
109-
)
118+
log_failed_call('attached node', 'master', device_path, vdi_uuid, remote_method, e)
110119

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

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

0 commit comments

Comments
 (0)