patroni.dcs.etcd3 module¶
-
exception
patroni.dcs.etcd3.
AuthFailed
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.InvalidArgument
-
error
= 'etcdserver: authentication failed, invalid user ID or password'¶
-
-
exception
patroni.dcs.etcd3.
AuthNotEnabled
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.FailedPrecondition
-
error
= 'etcdserver: authentication is not enabled'¶
-
-
exception
patroni.dcs.etcd3.
AuthOldRevision
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.InvalidArgument
-
error
= 'etcdserver: revision of auth store is old'¶
-
-
exception
patroni.dcs.etcd3.
DeadlineExceeded
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3ClientError
-
code
= 4¶
-
error
= 'context deadline exceeded'¶
-
-
class
patroni.dcs.etcd3.
Etcd3
(config: Dict[str, Any], mpp: patroni.postgresql.mpp.AbstractMPP)¶ Bases:
patroni.dcs.etcd.AbstractEtcd
-
__init__
(config: Dict[str, Any], mpp: patroni.postgresql.mpp.AbstractMPP) → None¶ Prepare DCS paths, MPP object, initial values for state information and processing dependencies.
Variables: config – dict
, reference to config section of selected DCS. i.e.:zookeeper
for zookeeper,etcd
for etcd, etc…
-
_abc_impl
= <_abc_data object>¶
-
_client
¶ return correct type of etcd client
-
_cluster_from_nodes
(nodes: Dict[str, Any]) → patroni.dcs.Cluster¶
-
_delete_leader
(*args, **kwargs) → Any¶
-
_do_attempt_to_acquire_leader
(retry: patroni.utils.Retry) → bool¶
-
_do_refresh_lease
(force: bool = False, retry: Optional[patroni.utils.Retry] = None) → bool¶
-
_load_cluster
(path: str, loader: Callable[[str], Union[patroni.dcs.Cluster, Dict[int, patroni.dcs.Cluster]]]) → Union[patroni.dcs.Cluster, Dict[int, patroni.dcs.Cluster]]¶ Main abstract method that implements the loading of
Cluster
instance.Note
Internally this method should call the loader method that will build
Cluster
object which represents current state and topology of the cluster in DCS. This method supposed to be called only by theget_cluster()
method.Parameters: - path – the path in DCS where to load Cluster(s) from.
- loader – one of
_postgresql_cluster_loader()
or_mpp_cluster_loader()
.
Raise: DCSError
in case of communication problems with DCS. If the current node was running as a primary and exception raised, instance would be demoted.
-
_mpp_cluster_loader
(path: str) → Dict[int, patroni.dcs.Cluster]¶ Load and build all PostgreSQL clusters from a single MPP cluster.
Parameters: path – the path in DCS where to load Cluster(s) from. Returns: all MPP groups as dict
, with group IDs as keys andCluster
objects as values.
-
_postgresql_cluster_loader
(path: str) → patroni.dcs.Cluster¶ Load and build the
Cluster
object from DCS, which represents a single PostgreSQL cluster.Parameters: path – the path in DCS where to load Cluster
from.Returns: Cluster
instance.
-
_update_leader
(**kwargs)¶
-
_write_failsafe
(*args, **kwargs) → Any¶
-
_write_leader_optime
(*args, **kwargs) → Any¶
-
_write_status
(*args, **kwargs) → Any¶
-
attempt_to_acquire_leader
(**kwargs)¶
-
cancel_initialization
(*args, **kwargs) → Any¶
-
cluster_prefix
¶ Construct the cluster prefix for the cluster.
Returns: path in the DCS under which we store information about this Patroni cluster.
-
create_lease
() → None¶
-
delete_cluster
(*args, **kwargs) → Any¶
-
delete_sync_state
(*args, **kwargs) → Any¶
-
initialize
(*args, **kwargs) → Any¶
-
static
member
(node: Dict[str, str]) → patroni.dcs.Member¶
-
refresh_lease
() → bool¶
-
set_config_value
(*args, **kwargs) → Any¶
-
set_failover_value
(*args, **kwargs) → Any¶
-
set_history_value
(*args, **kwargs) → Any¶
-
set_socket_options
(sock: socket.socket, socket_options: Optional[Collection[Tuple[int, int, int]]]) → None¶
-
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[str], 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.etcd3.
Etcd3Client
(config: Dict[str, Any], dns_resolver: patroni.dcs.etcd.DnsCachingResolver, cache_ttl: int = 300)¶ Bases:
patroni.dcs.etcd.AbstractEtcdClientWithFailover
-
ERROR_CLS
¶ alias of
Etcd3Error
-
__init__
(config: Dict[str, Any], dns_resolver: patroni.dcs.etcd.DnsCachingResolver, cache_ttl: int = 300) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
_abc_impl
= <_abc_data object>¶
-
_ensure_version_prefix
(base_uri: str, **kwargs) → None¶
-
_get_headers
() → Dict[str, str]¶
-
_get_members
(base_uri: str, **kwargs) → List[str]¶ returns: list of clientURLs
-
_handle_server_response
(response: urllib3.response.HTTPResponse) → Dict[str, Any]¶ Handles the server response
-
_prepare_get_members
(etcd_nodes: int) → Dict[str, Any]¶ returns: request parameters
-
_prepare_request
(kwargs: Dict[str, Any], params: Optional[Dict[str, Any]] = None, method: Optional[str] = None) → Callable[[...], urllib3.response.HTTPResponse]¶ returns: request_executor
-
authenticate
(*, retry: Optional[patroni.utils.Retry] = None) → bool¶
-
call_rpc
(method: str, fields: Dict[str, Any], retry: Optional[patroni.utils.Retry] = None) → Dict[str, Any]¶
-
deleteprefix
(key: str, *, retry: Optional[patroni.utils.Retry] = None) → Dict[str, Any]¶
-
deleterange
(*args, **kwargs) → Any¶
-
handle_auth_errors
(func: Callable[[...], Any], *args, retry: Optional[patroni.utils.Retry] = None, **kwargs) → Any¶
-
lease_grant
(*args, **kwargs) → Any¶
-
lease_keepalive
(ID: str, *, retry: Optional[patroni.utils.Retry] = None) → Optional[str]¶
-
prefix
(key: str, serializable: bool = True, *, retry: Optional[patroni.utils.Retry] = None) → Dict[str, Any]¶
-
put
(*args, **kwargs) → Any¶
-
range
(*args, **kwargs) → Any¶
-
txn
(*args, **kwargs) → Any¶
-
watchprefix
(key: str, start_revision: Optional[str] = None, filters: Optional[List[Dict[str, Any]]] = None, read_timeout: Optional[float] = None) → urllib3.response.HTTPResponse¶
-
watchrange
(key: str, range_end: Union[bytes, str, None] = None, start_revision: Optional[str] = None, filters: Optional[List[Dict[str, Any]]] = None, read_timeout: Optional[float] = None) → urllib3.response.HTTPResponse¶ returns: response object
-
-
exception
patroni.dcs.etcd3.
Etcd3ClientError
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3Exception
-
__init__
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
as_dict
() → Dict[str, Any]¶
-
classmethod
get_subclasses
() → Iterator[Type[patroni.dcs.etcd3.Etcd3ClientError]]¶
-
-
exception
patroni.dcs.etcd3.
Etcd3Error
(value: Any)¶ Bases:
patroni.exceptions.DCSError
-
exception
patroni.dcs.etcd3.
Etcd3Exception
(message=None, payload=None)¶ Bases:
etcd.EtcdException
-
exception
patroni.dcs.etcd3.
FailedPrecondition
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3ClientError
-
code
= 9¶
-
-
class
patroni.dcs.etcd3.
GRPCCode
¶ Bases:
enum.IntEnum
An enumeration.
-
Aborted
= 10¶
-
AlreadyExists
= 6¶
-
Canceled
= 1¶
-
DataLoss
= 15¶
-
DeadlineExceeded
= 4¶
-
FailedPrecondition
= 9¶
-
Internal
= 13¶
-
InvalidArgument
= 3¶
-
NotFound
= 5¶
-
OK
= 0¶
-
OutOfRange
= 11¶
-
PermissionDenied
= 7¶
-
ResourceExhausted
= 8¶
-
Unauthenticated
= 16¶
-
Unimplemented
= 12¶
-
Unknown
= 2¶
-
-
exception
patroni.dcs.etcd3.
InvalidArgument
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3ClientError
-
code
= 3¶
-
-
exception
patroni.dcs.etcd3.
InvalidAuthToken
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3ClientError
-
code
= 16¶
-
error
= 'etcdserver: invalid auth token'¶
-
-
class
patroni.dcs.etcd3.
KVCache
(dcs: patroni.dcs.etcd3.Etcd3, client: patroni.dcs.etcd3.PatroniEtcd3Client)¶ Bases:
threading.Thread
-
__init__
(dcs: patroni.dcs.etcd3.Etcd3, client: patroni.dcs.etcd3.PatroniEtcd3Client) → None¶ This constructor should always be called with keyword arguments. Arguments are:
group should be None; reserved for future extension when a ThreadGroup class is implemented.
target is the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
name is the thread name. By default, a unique name is constructed of the form “Thread-N” where N is a small decimal number.
args is the argument tuple for the target invocation. Defaults to ().
kwargs is a dictionary of keyword arguments for the target invocation. Defaults to {}.
If a subclass overrides the constructor, it must make sure to invoke the base class constructor (Thread.__init__()) before doing anything else to the thread.
-
_build_cache
() → None¶
-
_do_watch
(revision: str) → None¶
-
static
_finish_response
(response: urllib3.response.HTTPResponse) → None¶
-
_process_event
(event: Dict[str, Any]) → None¶
-
_process_message
(message: Dict[str, Any]) → None¶
-
copy
() → List[Dict[str, Any]]¶
-
delete
(name: str, mod_revision: str) → Tuple[bool, Optional[Dict[str, Any]]]¶
-
get
(name: str) → Optional[Dict[str, Any]]¶
-
is_ready
() → bool¶ Must be called only when holding the lock on condition
-
kill_stream
() → 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.
-
set
(value: Dict[str, Any], overwrite: bool = False) → Tuple[bool, Optional[Dict[str, Any]]]¶
-
-
exception
patroni.dcs.etcd3.
LeaseNotFound
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.NotFound
-
error
= 'etcdserver: requested lease not found'¶
-
-
exception
patroni.dcs.etcd3.
NotFound
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3ClientError
-
code
= 5¶
-
-
class
patroni.dcs.etcd3.
PatroniEtcd3Client
(*args, **kwargs)¶ Bases:
patroni.dcs.etcd3.Etcd3Client
-
__init__
(*args, **kwargs) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
_abc_impl
= <_abc_data object>¶
-
_restart_watcher
() → None¶
-
_wait_cache
(timeout: float) → None¶
-
call_rpc
(method: str, fields: Dict[str, Any], retry: Optional[patroni.utils.Retry] = None) → Dict[str, Any]¶
-
configure
(etcd3: patroni.dcs.etcd3.Etcd3) → None¶
-
get_cluster
(path: str) → List[Dict[str, Any]]¶
-
set_base_uri
(value: str) → None¶
-
start_watcher
() → None¶
-
txn
(compare: Dict[str, Any], success: Dict[str, Any], failure: Optional[Dict[str, Any]] = None, *, retry: Optional[patroni.utils.Retry] = None) → Dict[str, Any]¶
-
-
exception
patroni.dcs.etcd3.
PermissionDenied
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3ClientError
-
code
= 7¶
-
error
= 'etcdserver: permission denied'¶
-
-
exception
patroni.dcs.etcd3.
Unknown
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.Etcd3ClientError
-
code
= 2¶
-
-
exception
patroni.dcs.etcd3.
UnsupportedEtcdVersion
(value: Any)¶
-
exception
patroni.dcs.etcd3.
UserEmpty
(code: Optional[int] = None, error: Optional[str] = None, status: Optional[int] = None)¶ Bases:
patroni.dcs.etcd3.InvalidArgument
-
error
= 'etcdserver: user name is empty'¶
-
-
patroni.dcs.etcd3.
_handle_auth_errors
(func: Callable[[...], Any]) → Any¶
-
patroni.dcs.etcd3.
_raise_for_data
(data: Union[bytes, str, Dict[str, Union[Dict[str, Any], Any]]], status_code: Optional[int] = None) → patroni.dcs.etcd3.Etcd3ClientError¶
-
patroni.dcs.etcd3.
base64_decode
(v: str) → str¶
-
patroni.dcs.etcd3.
base64_encode
(v: Union[str, bytes]) → str¶
-
patroni.dcs.etcd3.
build_range_request
(key: str, range_end: Union[bytes, str, None] = None) → Dict[str, Any]¶
-
patroni.dcs.etcd3.
prefix_range_end
(v: str) → bytes¶
-
patroni.dcs.etcd3.
to_bytes
(v: Union[str, bytes]) → bytes¶