From 17c387439e830df72db26699a8b2a4add9c0e311 Mon Sep 17 00:00:00 2001 From: Sam Stoelinga Date: Fri, 27 Nov 2026 12:06:21 -0800 Subject: [PATCH] Handle cancelled Pathways sidecar sessions as elastic slice-loss errors. PiperOrigin-RevId: 1031372438 --- pathwaysutils/elastic/elastic.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pathwaysutils/elastic/elastic.py b/pathwaysutils/elastic/elastic.py index f20aecd..8ffd923 100644 --- a/pathwaysutils/elastic/elastic.py +++ b/pathwaysutils/elastic/elastic.py @@ -40,6 +40,13 @@ "NOT_FOUND", "INTERNAL", ]) +# Matched by message. The status code alone, CANCELLED, is also reported when +# the client disconnects from the IFRT proxy server. +_ELASTIC_DOWN_ADDITIONAL_ERROR_MESSAGES = frozenset([ + # The colocated Python sidecar of a slice went away with a call pending, + # for example because the pod of the slice was evicted. + "SidecarSession is cancelled", +]) class SliceHealthChecker(ABC): @@ -267,6 +274,8 @@ def is_error_due_to_slice_down( - DEADLINE_EXCEEDED - NOT_FOUND - INTERNAL + or with the following text in the message: + - SidecarSession is cancelled Args: error: The error to check. @@ -288,13 +297,17 @@ def is_error_due_to_slice_down( error_due_to_slice_down = True elif any( - error_type in str(error) - for error_type in _ELASTIC_DOWN_ADDITIONAL_ERROR_TYPES + pattern in str(error) + for pattern in ( + _ELASTIC_DOWN_ADDITIONAL_ERROR_TYPES + | _ELASTIC_DOWN_ADDITIONAL_ERROR_MESSAGES + ) ): _logger.warning( "Caught an error that may or may not be due to slice down (matched" - " _ELASTIC_DOWN_ADDITIONAL_ERROR_TYPES). This error will be treated" - " as due to slice down." + " _ELASTIC_DOWN_ADDITIONAL_ERROR_TYPES or" + " _ELASTIC_DOWN_ADDITIONAL_ERROR_MESSAGES). This error will be" + " treated as due to slice down." ) traceback_logging_level = logging.WARNING