patroni.postgresql.bootstrap module¶
-
class
patroni.postgresql.bootstrap.Bootstrap(postgresql: Postgresql)¶ Bases:
object-
__init__(postgresql: Postgresql) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
_custom_bootstrap(config: Any) → bool¶ 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
commandkey, which value is the command or script to perform the custom bootstrap procedure. The exit code of thecommanddictates if the bootstrap succeeded or failed.When calling
command, Patroni will pass the following arguments to thecommandcall:--scope: contains the value ofscopeconfiguration;--data_dir: contains the value of thepostgresql.data_dirconfiguration.
You can avoid that behavior by filling the optional key
no_paramswith the valueFalsein the configuration file, which will instruct Patroni to not pass these parameters to thecommandcall.Besides that, a couple more keys are supported in config, but optional:
keep_existing_recovery_conf: ifTrue, instruct Patroni to not remove the existingrecovery.conf(PostgreSQL <= 11), to not discard recovery parameters from the configuration (PostgreSQL >= 12), and to not remove the filesrecovery.signalorstandby.signal(PostgreSQL >= 12). This is specially useful when you are restoring backups through tools like pgBackRest and Barman, in which case they generated the appropriate recovery settings for you;recovery_conf: a section containing a map, where each key is the name of a recovery related setting, and the value is the value of the corresponding setting.
Any key/value other than the ones that were described above will be interpreted as additional arguments for the
commandcall. They will all be added to the call in the format--key=value.- Returns
Trueif the bootstrap was successful, i.e. the execution of the customcommandfrom config exited with code0,Falseotherwise.
-
_initdb(config: Any) → bool¶
-
static
_log_output_line(name: str, line: bytes) → None¶ Log a single line of
pg_basebackupoutput.- Parameters
name – name of the stream the line was read from,
stdoutorstderr.line – one line of output without the trailing newline.
-
_post_restore() → None¶
-
basebackup(conn_url: str, env: Dict[str, str], options: Dict[str, Any]) → Optional[int]¶
-
bootstrap(config: Dict[str, Any]) → bool¶ Initialize a new node from scratch and start it.
-
call_post_bootstrap(config: Dict[str, Any]) → bool¶ runs a script after initdb or custom bootstrap script is called and waits until completion.
-
clone(clone_member: Optional[Union[patroni.dcs.Leader, patroni.dcs.Member]], clone_from_leader: bool = False) → bool¶ initialize the replica from an existing member (primary or replica)
initialize the replica using the replica creation method that works without the replication connection (i.e. restore from on-disk base backup)
-
create_or_update_role(name: str, password: Optional[str], options: List[str]) → None¶
-
create_replica(clone_member: Optional[Union[patroni.dcs.Leader, patroni.dcs.Member]], clone_from_leader: bool = False) → Optional[int]¶ 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¶
-
post_bootstrap(config: Dict[str, Any], task: patroni.async_executor.CriticalTask) → Optional[bool]¶
-
property
running_custom_bootstrap¶
-