Skip to content
This repository was archived by the owner on Jan 23, 2024. It is now read-only.

Commit 16a30bc

Browse files
mctavishcopybara-github
authored andcommitted
Retry breakpoint updates on socket error.
Register and list breakpoint operations already behave in a sane manner on socket errors, but update breakpoint will currently drop the update and never retry it. PiperOrigin-RevId: 253993634 Change-Id: I253e6dc441fd2d306be27d8b728172019156ca44
1 parent 2bbc6aa commit 16a30bc

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

src/googleclouddebugger/gcp_hub_client.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import logging
2323
import os
2424
import platform
25+
import socket
2526
import sys
2627
import threading
2728
import time
@@ -418,17 +419,29 @@ def _TransmitBreakpointUpdates(self, service):
418419
# not be retried. All other errors are assumed to be transient.
419420
status = err.resp.status
420421
is_transient = ((status >= 500) or (status == 408))
421-
if is_transient and retry_count < self.max_transmit_attempts - 1:
422-
native.LogInfo('Failed to send breakpoint %s update: %s' % (
423-
breakpoint['id'], traceback.format_exc()))
424-
retry_list.append((breakpoint, retry_count + 1))
425-
elif is_transient:
426-
native.LogWarning(
427-
'Breakpoint %s retry count exceeded maximum' % breakpoint['id'])
422+
if is_transient:
423+
if retry_count < self.max_transmit_attempts - 1:
424+
native.LogInfo('Failed to send breakpoint %s update: %s' %
425+
(breakpoint['id'], traceback.format_exc()))
426+
retry_list.append((breakpoint, retry_count + 1))
427+
else:
428+
native.LogWarning('Breakpoint %s retry count exceeded maximum' %
429+
breakpoint['id'])
428430
else:
429431
# This is very common if multiple instances are sending final update
430432
# simultaneously.
431433
native.LogInfo('%s, breakpoint: %s' % (err, breakpoint['id']))
434+
except socket.error as err:
435+
if retry_count < self.max_transmit_attempts - 1:
436+
native.LogInfo(
437+
'Socket error %d while sending breakpoint %s update: %s' %
438+
(err.errno, breakpoint['id'], traceback.format_exc()))
439+
retry_list.append((breakpoint, retry_count + 1))
440+
else:
441+
native.LogWarning('Breakpoint %s retry count exceeded maximum' %
442+
breakpoint['id'])
443+
# Socket errors shouldn't persist like this; reconnect.
444+
reconnect = True
432445
except BaseException:
433446
native.LogWarning(
434447
'Fatal error sending breakpoint %s update: %s' % (

0 commit comments

Comments
 (0)