Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions pathwaysutils/elastic/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand All @@ -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

Expand Down
Loading