From 5d694c8cecc4f0adbc52280a1ed3ace7392a7c92 Mon Sep 17 00:00:00 2001 From: Andrew Date: Fri, 30 Sep 2022 03:44:44 -0500 Subject: [PATCH] [bitnami/postgresql-repmgr] Adds a new environment variable to set failover in repmgr (#8190) Added environment variable to configure REPMGR failover called REPMGR_FAILOVER. Signed-off-by: Andrew Graham Signed-off-by: Andrew Graham --- .../10/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh | 6 +++++- .../debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../11/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh | 6 +++++- .../debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../12/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh | 6 +++++- .../debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../13/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh | 6 +++++- .../debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ .../14/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh | 6 +++++- .../debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh | 2 ++ bitnami/postgresql-repmgr/README.md | 1 + 11 files changed, 36 insertions(+), 5 deletions(-) diff --git a/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh b/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh index abe1fea1c78c..149143c117d3 100644 --- a/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh +++ b/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh @@ -124,6 +124,10 @@ repmgr_validate() { print_validation_error "The allowed values for REPMGR_UPGRADE_EXTENSION are: yes or no." fi + if ! [[ "$REPMGR_FAILOVER" =~ ^(automatic|manual)$ ]]; then + print_validation_error "The allowed values for REPMGR_FAILOVER are: automatic or manual." + fi + [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -481,7 +485,7 @@ node_id=$(repmgr_get_node_id) node_name='${REPMGR_NODE_NAME}' location='${REPMGR_NODE_LOCATION}' conninfo='user=${REPMGR_USERNAME} $(repmgr_get_conninfo_password) host=${REPMGR_NODE_NETWORK_NAME} dbname=${REPMGR_DATABASE} port=${REPMGR_PORT_NUMBER} connect_timeout=${REPMGR_CONNECT_TIMEOUT}' -failover='automatic' +failover='${REPMGR_FAILOVER}' promote_command='$(repmgr_get_env_password) repmgr standby promote -f "${REPMGR_CONF_FILE}" --log-level DEBUG --verbose' follow_command='$(repmgr_get_env_password) repmgr standby follow -f "${REPMGR_CONF_FILE}" -W --log-level DEBUG --verbose' reconnect_attempts='${REPMGR_RECONNECT_ATTEMPTS}' diff --git a/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index 4e96a0b481a3..39ff8fc10c9e 100644 --- a/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql-repmgr/10/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -113,6 +113,7 @@ postgresql_env_vars=( REPMGR_DEGRADED_MONITORING_TIMEOUT REPMGR_UPGRADE_EXTENSION REPMGR_FENCE_OLD_PRIMARY + REPMGR_FAILOVER REPMGR_CHILD_NODES_CHECK_INTERVAL REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT @@ -407,6 +408,7 @@ export REPMGR_MASTER_RESPONSE_TIMEOUT="${REPMGR_MASTER_RESPONSE_TIMEOUT:-20}" export REPMGR_DEGRADED_MONITORING_TIMEOUT="${REPMGR_DEGRADED_MONITORING_TIMEOUT:-5}" export REPMGR_UPGRADE_EXTENSION="${REPMGR_UPGRADE_EXTENSION:-no}" export REPMGR_FENCE_OLD_PRIMARY="${REPMGR_FENCE_OLD_PRIMARY:-no}" +export REPMGR_FAILOVER="${REPMGR_FAILOVER:-automatic}" export REPMGR_CHILD_NODES_CHECK_INTERVAL="${REPMGR_CHILD_NODES_CHECK_INTERVAL:-5}" export REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT="${REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT:-1}" export REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT="${REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT:-30}" diff --git a/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh b/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh index abe1fea1c78c..f89ef30321cf 100644 --- a/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh +++ b/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh @@ -124,6 +124,10 @@ repmgr_validate() { print_validation_error "The allowed values for REPMGR_UPGRADE_EXTENSION are: yes or no." fi + if ! [[ "$REPMGR_FAILOVER" =~ ^(automatic|manual)$ ]]; then + print_validation_error "The allowed values for REPMGR_FAILOVER are: automatic or manual." + fi + [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -481,7 +485,7 @@ node_id=$(repmgr_get_node_id) node_name='${REPMGR_NODE_NAME}' location='${REPMGR_NODE_LOCATION}' conninfo='user=${REPMGR_USERNAME} $(repmgr_get_conninfo_password) host=${REPMGR_NODE_NETWORK_NAME} dbname=${REPMGR_DATABASE} port=${REPMGR_PORT_NUMBER} connect_timeout=${REPMGR_CONNECT_TIMEOUT}' -failover='automatic' +failover='${REPMGR_FAILOVER}' promote_command='$(repmgr_get_env_password) repmgr standby promote -f "${REPMGR_CONF_FILE}" --log-level DEBUG --verbose' follow_command='$(repmgr_get_env_password) repmgr standby follow -f "${REPMGR_CONF_FILE}" -W --log-level DEBUG --verbose' reconnect_attempts='${REPMGR_RECONNECT_ATTEMPTS}' diff --git a/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index 4e96a0b481a3..39ff8fc10c9e 100644 --- a/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql-repmgr/11/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -113,6 +113,7 @@ postgresql_env_vars=( REPMGR_DEGRADED_MONITORING_TIMEOUT REPMGR_UPGRADE_EXTENSION REPMGR_FENCE_OLD_PRIMARY + REPMGR_FAILOVER REPMGR_CHILD_NODES_CHECK_INTERVAL REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT @@ -407,6 +408,7 @@ export REPMGR_MASTER_RESPONSE_TIMEOUT="${REPMGR_MASTER_RESPONSE_TIMEOUT:-20}" export REPMGR_DEGRADED_MONITORING_TIMEOUT="${REPMGR_DEGRADED_MONITORING_TIMEOUT:-5}" export REPMGR_UPGRADE_EXTENSION="${REPMGR_UPGRADE_EXTENSION:-no}" export REPMGR_FENCE_OLD_PRIMARY="${REPMGR_FENCE_OLD_PRIMARY:-no}" +export REPMGR_FAILOVER="${REPMGR_FAILOVER:-automatic}" export REPMGR_CHILD_NODES_CHECK_INTERVAL="${REPMGR_CHILD_NODES_CHECK_INTERVAL:-5}" export REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT="${REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT:-1}" export REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT="${REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT:-30}" diff --git a/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh b/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh index abe1fea1c78c..f89ef30321cf 100644 --- a/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh +++ b/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh @@ -124,6 +124,10 @@ repmgr_validate() { print_validation_error "The allowed values for REPMGR_UPGRADE_EXTENSION are: yes or no." fi + if ! [[ "$REPMGR_FAILOVER" =~ ^(automatic|manual)$ ]]; then + print_validation_error "The allowed values for REPMGR_FAILOVER are: automatic or manual." + fi + [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -481,7 +485,7 @@ node_id=$(repmgr_get_node_id) node_name='${REPMGR_NODE_NAME}' location='${REPMGR_NODE_LOCATION}' conninfo='user=${REPMGR_USERNAME} $(repmgr_get_conninfo_password) host=${REPMGR_NODE_NETWORK_NAME} dbname=${REPMGR_DATABASE} port=${REPMGR_PORT_NUMBER} connect_timeout=${REPMGR_CONNECT_TIMEOUT}' -failover='automatic' +failover='${REPMGR_FAILOVER}' promote_command='$(repmgr_get_env_password) repmgr standby promote -f "${REPMGR_CONF_FILE}" --log-level DEBUG --verbose' follow_command='$(repmgr_get_env_password) repmgr standby follow -f "${REPMGR_CONF_FILE}" -W --log-level DEBUG --verbose' reconnect_attempts='${REPMGR_RECONNECT_ATTEMPTS}' diff --git a/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index 4e96a0b481a3..39ff8fc10c9e 100644 --- a/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql-repmgr/12/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -113,6 +113,7 @@ postgresql_env_vars=( REPMGR_DEGRADED_MONITORING_TIMEOUT REPMGR_UPGRADE_EXTENSION REPMGR_FENCE_OLD_PRIMARY + REPMGR_FAILOVER REPMGR_CHILD_NODES_CHECK_INTERVAL REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT @@ -407,6 +408,7 @@ export REPMGR_MASTER_RESPONSE_TIMEOUT="${REPMGR_MASTER_RESPONSE_TIMEOUT:-20}" export REPMGR_DEGRADED_MONITORING_TIMEOUT="${REPMGR_DEGRADED_MONITORING_TIMEOUT:-5}" export REPMGR_UPGRADE_EXTENSION="${REPMGR_UPGRADE_EXTENSION:-no}" export REPMGR_FENCE_OLD_PRIMARY="${REPMGR_FENCE_OLD_PRIMARY:-no}" +export REPMGR_FAILOVER="${REPMGR_FAILOVER:-automatic}" export REPMGR_CHILD_NODES_CHECK_INTERVAL="${REPMGR_CHILD_NODES_CHECK_INTERVAL:-5}" export REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT="${REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT:-1}" export REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT="${REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT:-30}" diff --git a/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh b/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh index abe1fea1c78c..a0a770af0441 100644 --- a/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh +++ b/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh @@ -123,6 +123,10 @@ repmgr_validate() { if ! is_yes_no_value "$REPMGR_UPGRADE_EXTENSION"; then print_validation_error "The allowed values for REPMGR_UPGRADE_EXTENSION are: yes or no." fi + + if ! [[ "$REPMGR_FAILOVER" =~ ^(automatic|manual)$ ]]; then + print_validation_error "The allowed values for REPMGR_FAILOVER are: automatic or manual." + fi [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -481,7 +485,7 @@ node_id=$(repmgr_get_node_id) node_name='${REPMGR_NODE_NAME}' location='${REPMGR_NODE_LOCATION}' conninfo='user=${REPMGR_USERNAME} $(repmgr_get_conninfo_password) host=${REPMGR_NODE_NETWORK_NAME} dbname=${REPMGR_DATABASE} port=${REPMGR_PORT_NUMBER} connect_timeout=${REPMGR_CONNECT_TIMEOUT}' -failover='automatic' +failover='${REPMGR_FAILOVER}' promote_command='$(repmgr_get_env_password) repmgr standby promote -f "${REPMGR_CONF_FILE}" --log-level DEBUG --verbose' follow_command='$(repmgr_get_env_password) repmgr standby follow -f "${REPMGR_CONF_FILE}" -W --log-level DEBUG --verbose' reconnect_attempts='${REPMGR_RECONNECT_ATTEMPTS}' diff --git a/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index 4e96a0b481a3..39ff8fc10c9e 100644 --- a/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql-repmgr/13/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -113,6 +113,7 @@ postgresql_env_vars=( REPMGR_DEGRADED_MONITORING_TIMEOUT REPMGR_UPGRADE_EXTENSION REPMGR_FENCE_OLD_PRIMARY + REPMGR_FAILOVER REPMGR_CHILD_NODES_CHECK_INTERVAL REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT @@ -407,6 +408,7 @@ export REPMGR_MASTER_RESPONSE_TIMEOUT="${REPMGR_MASTER_RESPONSE_TIMEOUT:-20}" export REPMGR_DEGRADED_MONITORING_TIMEOUT="${REPMGR_DEGRADED_MONITORING_TIMEOUT:-5}" export REPMGR_UPGRADE_EXTENSION="${REPMGR_UPGRADE_EXTENSION:-no}" export REPMGR_FENCE_OLD_PRIMARY="${REPMGR_FENCE_OLD_PRIMARY:-no}" +export REPMGR_FAILOVER="${REPMGR_FAILOVER:-automatic}" export REPMGR_CHILD_NODES_CHECK_INTERVAL="${REPMGR_CHILD_NODES_CHECK_INTERVAL:-5}" export REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT="${REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT:-1}" export REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT="${REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT:-30}" diff --git a/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh b/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh index abe1fea1c78c..149143c117d3 100644 --- a/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh +++ b/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/librepmgr.sh @@ -124,6 +124,10 @@ repmgr_validate() { print_validation_error "The allowed values for REPMGR_UPGRADE_EXTENSION are: yes or no." fi + if ! [[ "$REPMGR_FAILOVER" =~ ^(automatic|manual)$ ]]; then + print_validation_error "The allowed values for REPMGR_FAILOVER are: automatic or manual." + fi + [[ "$error_code" -eq 0 ]] || exit "$error_code" } @@ -481,7 +485,7 @@ node_id=$(repmgr_get_node_id) node_name='${REPMGR_NODE_NAME}' location='${REPMGR_NODE_LOCATION}' conninfo='user=${REPMGR_USERNAME} $(repmgr_get_conninfo_password) host=${REPMGR_NODE_NETWORK_NAME} dbname=${REPMGR_DATABASE} port=${REPMGR_PORT_NUMBER} connect_timeout=${REPMGR_CONNECT_TIMEOUT}' -failover='automatic' +failover='${REPMGR_FAILOVER}' promote_command='$(repmgr_get_env_password) repmgr standby promote -f "${REPMGR_CONF_FILE}" --log-level DEBUG --verbose' follow_command='$(repmgr_get_env_password) repmgr standby follow -f "${REPMGR_CONF_FILE}" -W --log-level DEBUG --verbose' reconnect_attempts='${REPMGR_RECONNECT_ATTEMPTS}' diff --git a/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh b/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh index 4e96a0b481a3..39ff8fc10c9e 100644 --- a/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh +++ b/bitnami/postgresql-repmgr/14/debian-11/rootfs/opt/bitnami/scripts/postgresql-env.sh @@ -113,6 +113,7 @@ postgresql_env_vars=( REPMGR_DEGRADED_MONITORING_TIMEOUT REPMGR_UPGRADE_EXTENSION REPMGR_FENCE_OLD_PRIMARY + REPMGR_FAILOVER REPMGR_CHILD_NODES_CHECK_INTERVAL REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT @@ -407,6 +408,7 @@ export REPMGR_MASTER_RESPONSE_TIMEOUT="${REPMGR_MASTER_RESPONSE_TIMEOUT:-20}" export REPMGR_DEGRADED_MONITORING_TIMEOUT="${REPMGR_DEGRADED_MONITORING_TIMEOUT:-5}" export REPMGR_UPGRADE_EXTENSION="${REPMGR_UPGRADE_EXTENSION:-no}" export REPMGR_FENCE_OLD_PRIMARY="${REPMGR_FENCE_OLD_PRIMARY:-no}" +export REPMGR_FAILOVER="${REPMGR_FAILOVER:-automatic}" export REPMGR_CHILD_NODES_CHECK_INTERVAL="${REPMGR_CHILD_NODES_CHECK_INTERVAL:-5}" export REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT="${REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT:-1}" export REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT="${REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT:-30}" diff --git a/bitnami/postgresql-repmgr/README.md b/bitnami/postgresql-repmgr/README.md index b1c5ee095526..a2aa622b2473 100644 --- a/bitnami/postgresql-repmgr/README.md +++ b/bitnami/postgresql-repmgr/README.md @@ -549,6 +549,7 @@ Please see the list of environment variables available in the Bitnami PostgreSQL | REPMGR_PASSWORD | `nil` | | REPMGR_PASSWORD_FILE | `nil` | | REPMGR_FENCE_OLD_PRIMARY | `no` | +| REPMGR_FAILOVER | `automatic` | | REPMGR_CHILD_NODES_CHECK_INTERVAL | `5` | | REPMGR_CHILD_NODES_CONNECTED_MIN_COUNT | `1` | | REPMGR_CHILD_NODES_DISCONNECT_TIMEOUT | `30` |