Skip to content

Commit 4130661

Browse files
committed
Add more debug logs
1 parent 6798e84 commit 4130661

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

juju/client/connection.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ async def close(self, to_reconnect=False):
450450
self._debug_log_task.cancel()
451451

452452
if self._ws and not self._ws.closed:
453+
log.debug('close: calling websocket.close()')
453454
await self._ws.close()
454455

455456
if not to_reconnect:
@@ -463,6 +464,7 @@ async def close(self, to_reconnect=False):
463464
pass
464465
except websockets.exceptions.ConnectionClosed:
465466
pass
467+
log.debug('close: all tasks are done')
466468

467469
self._pinger_task = None
468470
self._receiver_task = None
@@ -595,6 +597,7 @@ async def _receiver(self):
595597
raise
596598

597599
async def _pinger(self):
600+
log.warning('Pinger: Starting')
598601
'''
599602
A Controller can time us out if we are silent for too long. This
600603
is especially true in JaaS, which has a fairly strict timeout.
@@ -604,6 +607,7 @@ async def _pinger(self):
604607
'''
605608
async def _do_ping():
606609
try:
610+
log.debug(f'Pinger {self._pinger_task}: pinging')
607611
await pinger_facade.Ping()
608612
except jasyncio.CancelledError:
609613
raise
@@ -643,7 +647,7 @@ async def rpc(self, msg, encoder=None):
643647
if "version" not in msg:
644648
msg['version'] = self.facades[msg['type']]
645649
outgoing = json.dumps(msg, indent=2, cls=encoder)
646-
log.debug('connection {} -> {}'.format(id(self), outgoing))
650+
log.debug('connection id: {} -- sending {}'.format(id(self), outgoing))
647651
for attempt in range(3):
648652
if self.monitor.status == Monitor.DISCONNECTED:
649653
# closed cleanly; shouldn't try to reconnect
@@ -666,7 +670,7 @@ async def rpc(self, msg, encoder=None):
666670
log.error('RPC: Automatic reconnect failed')
667671
raise
668672
result = await self._recv(msg['request-id'])
669-
log.debug('connection {} <- {}'.format(id(self), result))
673+
log.debug('connection id : {} -- receiving {}'.format(id(self), result))
670674

671675
if not result:
672676
return result
@@ -797,6 +801,7 @@ async def reconnect(self):
797801
if not self.is_debug_log_connection:
798802
self._build_facades(res.get('facades', {}))
799803
if not self._pinger_task:
804+
log.debug('reconnect: creating pinger task')
800805
self._pinger_task = jasyncio.create_task(self._pinger(), name="Task_Pinger")
801806

802807
async def _connect(self, endpoints):
@@ -853,6 +858,7 @@ async def _try_endpoint(endpoint, cacert, delay):
853858
# If this is regular connection, and we dont have a
854859
# receiver_task yet, then schedule a _receiver_task
855860
elif not self.is_debug_log_connection and not self._receiver_task:
861+
log.debug('_connect: creating receiver task')
856862
self._receiver_task = jasyncio.create_task(self._receiver(), name="Task_Receiver")
857863

858864
log.debug("Driver connected to juju %s", self.addr)
@@ -908,6 +914,7 @@ async def _connect_with_redirect(self, endpoints):
908914
login_result = await self._connect_with_login(e.endpoints)
909915
self._build_facades(login_result.get('facades', {}))
910916
if not self._pinger_task:
917+
log.debug('_connect_with_redirect: creating pinger task')
911918
self._pinger_task = jasyncio.create_task(self._pinger(), name="Task_Pinger")
912919

913920
# _build_facades takes the facade list that comes from the connection with the controller,

0 commit comments

Comments
 (0)