patroni.postgresql.bootstrap module

class _patroni.postgresql.bootstrap.Bootstrap(_postgresql: Postgresql) View on GitHub

Bases: object +

__init\\__(postgresql: Postgresql) → None View on GitHub

+

custom_bootstrap(_config: Any) → bool View on GitHub

Bootstrap a fresh Patroni cluster using a custom method provided by the user. +

Parameters

config – configuration used for running a custom bootstrap method. It comes from the Patroni YAML file, so it is expected to be a dict. + Note

_config_ must contain a `+command+` key, which value is the command or script to perform the custom bootstrap procedure. The exit code of the `+command+` dictates if the bootstrap succeeded or failed.
When calling `+command+`, Patroni will pass the following arguments to the `+command+` call:
\\__\\__
\\__\\__
You can avoid that behavior by filling the optional key `+no_params+` with the value `+False+` in the configuration file, which will instruct Patroni to not pass these parameters to the `+command+` call.
Besides that, a couple more keys are supported in _config_, but optional:
\\__\\__
\\__\\__
Any key/value other than the ones that were described above will be interpreted as additional arguments for the `+command+` call. They will all be added to the call in the format `+--key=value+`.
+
Returns

True if the bootstrap was successful, i.e. the execution of the custom command from config exited with code 0, False otherwise. +

initdb(_config: Any) → bool View on GitHub

+

_post_restore() → None View on GitHub

+

basebackup(conn_url: str, env: Dict[ str, str], options: Dict[ str, Any]) → int | None View on GitHub

+

bootstrap(config: Dict[ str, Any]) → bool View on GitHub

Initialize a new node from scratch and start it. +

call_post_bootstrap(config: Dict[ str, Any]) → bool View on GitHub

runs a script after initdb or custom bootstrap script is called and waits until completion. +

clone(clone_member: Leader | Member | None) → bool View on GitHub

+

create_or_update_role(name: str, password: str | None, options: List[ str]) → None View on GitHub

+

create_replica(clone_member: Leader | Member | None) → int | None View on GitHub

create the replica according to the replica_method defined by the user. this is a list, so we need to loop through all methods the user supplies +

property _keep_existing_recovery_conf: bool_

+

post_bootstrap(config: Dict[ str, Any], task: CriticalTask) → bool | None View on GitHub

+

static _process_user_options(_tool: str, options: Any | Dict[ str, str] | List[ str | Dict[ str, Any]], not_allowed_options: Tuple[ str, …​], error_handler: Callable[[ str], None]) → List[ str] View on GitHub

Format options in a list or dictionary format into command line long form arguments. + Note

The format of the output of this method is to prepare arguments for use in the `+initdb+` method of self._postgres.
+
Example:::
  The _options_ can be defined as a dictionary of key, values to be converted into arguments: >>> Bootstrap.process_user_options(‘foo’, \{‘foo’: ‘bar’}, (), print) [’–foo=bar’]
  +
  Or as a list of single string arguments >>> Bootstrap.process_user_options(‘foo’, [‘yes’], (), print) [’–yes’]
  +
  Or as a list of key, value options >>> Bootstrap.process_user_options(‘foo’, [\{‘foo’: ‘bar’}], (), print) [’–foo=bar’]
  +
  Or a combination of single and key, values >>> Bootstrap.process_user_options(‘foo’, [‘yes’, \{‘foo’: ‘bar’}], (), print) [’–yes’, ‘–foo=bar’]
  +
  Options that contain spaces are passed as is to `+subprocess.call+` >>> Bootstrap.process_user_options(‘foo’, [\{‘foo’: ‘bar baz’}], (), print) [’–foo=bar baz’]
  +
  Options that are quoted will be unquoted, so the quotes aren’t interpreted literally by the postgres command >>> Bootstrap.process_user_options(‘foo’, [\{‘foo’: ‘“bar baz”’}], (), print) [’–foo=bar baz’]
+
Note
  The _error_handler_ is called when any of these conditions are met:
  +
  Parameters:::
  Returns:::
    List of long form arguments to pass to the named tool
+
property _running_custom_bootstrap: bool_

© Copyright 2015 Compose, Zalando SE. Revision 9d231aee.

Built with Sphinx using a theme provided by Read the Docs.

Read the Docs v: latest

+ Builds