From 9498e87e9c104bee14c603816d7d2cdd07ee01b9 Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 26 Aug 2023 22:27:10 +0200 Subject: [PATCH] modules/patroni: pause patroni during upgrade, disable python stdout buffering for migration script --- modules/patroni/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/patroni/default.nix b/modules/patroni/default.nix index 9ed7da8..20851f2 100644 --- a/modules/patroni/default.nix +++ b/modules/patroni/default.nix @@ -361,6 +361,7 @@ in print(f"setting system identifier to {sysid}") ctl.dcs.initialize(create_new=False, sysid=str(sysid)) pg.stop() + os.system("patronictl resume") ''; migrationScript = pkgs.writeShellScript "patroni-migration-replicate-or-self-upgrade" '' if [[ "$(consul catalog nodes --service='${cfg.scope}' 2>/dev/null | wc -l)" -gt 0 ]]; then @@ -398,6 +399,7 @@ in fi done echo no other nodes are at the target version, performing self-upgrade + patronictl pause leaderHost="$(patronictl list -f json | jq -r 'map(select(.Role == "Leader" and .State == "running") | .Host) | .[0]')" # this is where it gets spicy rm -rf '${cfg.postgresqlDataDir}' @@ -407,6 +409,7 @@ in export PATRONIMIGRATOR_LEADER_HOST="$leaderHost" # HACK: find a way to get the port export PATRONIMIGRATOR_LEADER_PORT="5432" + export PYTHONUNBUFFERED=1 exec ${upgradeScript} fi fi