Skip to main content

Overview

The constants module provides commonly used timeout values and exception dictionaries for handling transient cluster errors during API operations.

Timeout Constants

Predefined timeout values in seconds for various operations.

TIMEOUT_1SEC

One second timeout for quick operations. Usage:

TIMEOUT_5SEC

Five second timeout for short operations.

TIMEOUT_10SEC

Ten second timeout for brief operations. This is the default timeout for cluster retry operations. Usage:

TIMEOUT_30SEC

Thirty second timeout for moderate operations.

TIMEOUT_1MINUTE

One minute (60 seconds) timeout. This is the default timeout for most resource operations. Usage:

TIMEOUT_2MINUTES

Two minute (120 seconds) timeout for longer operations.

TIMEOUT_4MINUTES

Four minute (240 seconds) timeout. This is the default timeout for resource deletion and waiting operations. Usage:

TIMEOUT_10MINUTES

Ten minute (600 seconds) timeout for extended operations. Usage:

Exception Dictionaries

Dictionaries mapping exception types to lists of error message patterns. These are used with TimeoutSampler to automatically retry operations on transient cluster errors.

DEFAULT_CLUSTER_RETRY_EXCEPTIONS

Default exceptions that should trigger automatic retries during cluster operations.

Exception Types

list[str]
Network-level retry errors. Empty list means retry on any MaxRetryError.
list[str]
Connection aborted errors. Empty list means retry on any ConnectionAbortedError.
list[str]
Connection reset errors. Empty list means retry on any ConnectionResetError.
list[str]
Kubernetes API server internal errors. Retries only on specific error messages:
  • etcd leader changes
  • etcd timeouts
  • Webhook failures
  • RPC errors
list[str]
API server timeout errors. Empty list means retry on any ServerTimeoutError.
list[str]
Forbidden errors caused by timeouts. Retries only on “context deadline exceeded”.

Usage Example


PROTOCOL_ERROR_EXCEPTION_DICT

Exception dictionary for handling protocol-level errors.
Usage:

NOT_FOUND_ERROR_EXCEPTION_DICT

Exception dictionary for handling resource not found errors.
Usage:

Complete Example

Here’s a comprehensive example using multiple constants:

Exception Dictionary Merging

You can combine multiple exception dictionaries for comprehensive error handling:

Custom Exception Patterns

You can extend exception dictionaries with your own patterns: