patroni.dcs.etcd module¶
-
class
patroni.dcs.etcd.
AbstractEtcd
(config: Dict[str, Any], client_cls: Type[patroni.dcs.etcd.AbstractEtcdClientWithFailover], retry_errors_cls: Union[Type[Exception], Tuple[Type[Exception], ...]])¶ Bases:
patroni.dcs.AbstractDCS
-
get_etcd_client
(config: Dict[str, Any], client_cls: Type[patroni.dcs.etcd.AbstractEtcdClientWithFailover]) → patroni.dcs.etcd.AbstractEtcdClientWithFailover¶
-
handle_etcd_exceptions
(func: Callable[[...], Any], *args, **kwargs) → Any¶
-
reload_config
(config: Union[Config, Dict[str, Any]]) → None¶ Load and set relevant values from configuration.
Sets
loop_wait
,ttl
andretry_timeout
properties.Parameters: config – Loaded configuration information object or dictionary of key value pairs.
-
retry
(method: Callable[[...], Any], *args, **kwargs) → Any¶
-
set_retry_timeout
(retry_timeout: int) → None¶ Set the new value for retry_timeout.
-
set_socket_options
(sock: socket.socket, socket_options: Optional[Collection[Tuple[int, int, int]]]) → None¶
-
set_ttl
(ttl: int) → Optional[bool]¶ Set the new ttl value for DCS keys.
-
ttl
¶ Get current
ttl
value.
-
-
class
patroni.dcs.etcd.
AbstractEtcdClientWithFailover
(config: Dict[str, Any], dns_resolver: patroni.dcs.etcd.DnsCachingResolver, cache_ttl: int = 300)¶ Bases:
abc.ABC
,etcd.client.Client
-
api_execute
(path: str, method: str, params: Optional[Dict[str, Any]] = None, timeout: Optional[float] = None) → Any¶ Executes the query.
-
static
get_srv_record
(host: str) → List[Tuple[str, int]]¶
-
machines
¶ Original machines method(property) of etcd.Client class raise exception when it failed to get list of etcd cluster members. This method is being called only when request failed on one of the etcd members during api_execute call. For us it’s more important to execute original request rather then get new topology of etcd cluster. So we will catch this exception and return empty list of machines. Later, during next api_execute call we will forcefully update machines_cache.
Also this method implements the same timeout-retry logic as api_execute, because the original method was retrying 2 times with the read_timeout on each node.
After the next refactoring the whole logic was moved to the _get_machines_list() method.
-
machines_cache
¶
-
reload_config
(config: Dict[str, Any]) → None¶
-
set_base_uri
(value: str) → None¶
-
set_machines_cache_ttl
(cache_ttl: int) → None¶
-
set_read_timeout
(timeout: float) → None¶
-
-
class
patroni.dcs.etcd.
DnsCachingResolver
(cache_time: float = 600.0, cache_fail_time: float = 30.0)¶ Bases:
threading.Thread
-
remove
(host: str, port: int) → None¶
-
resolve
(host: str, port: int) → List[Tuple[socket.AddressFamily, socket.SocketKind, int, str, Union[Tuple[str, int], Tuple[str, int, int, int]]]]¶
-
resolve_async
(host: str, port: int, attempt: int = 0) → None¶
-
run
() → None¶ Method representing the thread’s activity.
You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.
-
-
class
patroni.dcs.etcd.
Etcd
(config: Dict[str, Any])¶ Bases:
patroni.dcs.etcd.AbstractEtcd
-
attempt_to_acquire_leader
(**kwargs)¶
-
cancel_initialization
(*args, **kwargs) → Any¶
-
delete_cluster
(*args, **kwargs) → Any¶
-
delete_sync_state
(*args, **kwargs) → Any¶
-
initialize
(*args, **kwargs) → Any¶
-
static
member
(node: etcd.EtcdResult) → patroni.dcs.Member¶
-
set_config_value
(*args, **kwargs) → Any¶
-
set_failover_value
(*args, **kwargs) → Any¶
-
set_history_value
(*args, **kwargs) → Any¶
-
set_sync_state_value
(*args, **kwargs) → Any¶
-
set_ttl
(ttl: int) → Optional[bool]¶ Set the new ttl value for DCS keys.
-
take_leader
(*args, **kwargs) → Any¶
-
touch_member
(*args, **kwargs) → Any¶
-
watch
(leader_version: Optional[int], timeout: float) → bool¶ Sleep if the current node is a leader, otherwise, watch for changes of leader key with a given timeout.
Parameters: - leader_version – version of a leader key.
- timeout – timeout in seconds.
Returns: if
True
this will reschedule the next run of the HA cycle.
-
-
class
patroni.dcs.etcd.
EtcdClient
(config: Dict[str, Any], dns_resolver: patroni.dcs.etcd.DnsCachingResolver, cache_ttl: int = 300)¶
-
exception
patroni.dcs.etcd.
EtcdError
(value: Any)¶ Bases:
patroni.exceptions.DCSError
-
exception
patroni.dcs.etcd.
EtcdRaftInternal
(message=None, payload=None)¶ Bases:
etcd.EtcdException
Raft Internal Error
-
patroni.dcs.etcd.
catch_etcd_errors
(func: Callable[[...], Any]) → Any¶