From efa8f2c8b95a0eb1f742057b6377003fd56c2b63 Mon Sep 17 00:00:00 2001 From: Bitnami Bot Date: Tue, 19 Aug 2025 16:58:24 +0200 Subject: [PATCH] [bitnami/postgresql-repmgr] Release 17.6.0-debian-12-r1 (#85490) Signed-off-by: Bitnami Bot --- .../postgresql-repmgr/17/debian-12/Dockerfile | 3 +- .../opt/bitnami/scripts/libservice.sh | 74 ----------------- .../opt/bitnami/scripts/libwebserver.sh | 80 ------------------- .../rootfs/opt/bitnami/scripts/librepmgr.sh | 61 +++++++++++--- 4 files changed, 53 insertions(+), 165 deletions(-) diff --git a/bitnami/postgresql-repmgr/17/debian-12/Dockerfile b/bitnami/postgresql-repmgr/17/debian-12/Dockerfile index 76c9e743dec2..590cad1330fe 100644 --- a/bitnami/postgresql-repmgr/17/debian-12/Dockerfile +++ b/bitnami/postgresql-repmgr/17/debian-12/Dockerfile @@ -8,7 +8,7 @@ ARG TARGETARCH LABEL com.vmware.cp.artifact.flavor="sha256:c50c90cfd9d12b445b011e6ad529f1ad3daea45c26d20b00732fae3cd71f6a83" \ org.opencontainers.image.base.name="docker.io/bitnami/minideb:bookworm" \ - org.opencontainers.image.created="2025-08-14T16:37:45Z" \ + org.opencontainers.image.created="2025-08-19T14:46:33Z" \ org.opencontainers.image.description="Application packaged by Broadcom, Inc." \ org.opencontainers.image.documentation="https://github.com/bitnami/containers/tree/main/bitnami/postgresql-repmgr/README.md" \ org.opencontainers.image.source="https://github.com/bitnami/containers/tree/main/bitnami/postgresql-repmgr" \ @@ -59,6 +59,7 @@ RUN echo 'en_GB.UTF-8 UTF-8' >> /etc/locale.gen RUN /opt/bitnami/scripts/locales/generate-locales.sh ENV APP_VERSION="17.6.0" \ BITNAMI_APP_NAME="postgresql-repmgr" \ + IMAGE_REVISION="1" \ LANG="en_US.UTF-8" \ LANGUAGE="en_US:en" \ NSS_WRAPPER_LIB="/opt/bitnami/common/lib/libnss_wrapper.so" \ diff --git a/bitnami/postgresql-repmgr/17/debian-12/prebuildfs/opt/bitnami/scripts/libservice.sh b/bitnami/postgresql-repmgr/17/debian-12/prebuildfs/opt/bitnami/scripts/libservice.sh index 1f9b33096b02..886962ebd276 100644 --- a/bitnami/postgresql-repmgr/17/debian-12/prebuildfs/opt/bitnami/scripts/libservice.sh +++ b/bitnami/postgresql-repmgr/17/debian-12/prebuildfs/opt/bitnami/scripts/libservice.sh @@ -142,80 +142,6 @@ EOF fi } -######################## -# Remove a cron configuration file for a given service -# Arguments: -# $1 - Service name -# Returns: -# None -######################### -remove_cron_conf() { - local service_name="${1:?service name is missing}" - local cron_conf_dir="/etc/monit/conf.d" - rm -f "${cron_conf_dir}/${service_name}" -} - -######################## -# Generate a monit configuration file for a given service -# Arguments: -# $1 - Service name -# $2 - Pid file -# $3 - Start command -# $4 - Stop command -# Flags: -# --disable - Whether to disable the monit configuration -# Returns: -# None -######################### -generate_monit_conf() { - local service_name="${1:?service name is missing}" - local pid_file="${2:?pid file is missing}" - local start_command="${3:?start command is missing}" - local stop_command="${4:?stop command is missing}" - local monit_conf_dir="/etc/monit/conf.d" - local disabled="no" - - # Parse optional CLI flags - shift 4 - while [[ "$#" -gt 0 ]]; do - case "$1" in - --disable) - disabled="yes" - ;; - *) - echo "Invalid command line flag ${1}" >&2 - return 1 - ;; - esac - shift - done - - is_boolean_yes "$disabled" && conf_suffix=".disabled" - mkdir -p "$monit_conf_dir" - cat > "${monit_conf_dir}/${service_name}.conf${conf_suffix:-}" <&1 +} + ######################## # Execute repmgr command # Globals: @@ -25,15 +46,7 @@ # None ######################## repmgr_execute() { - local repmgr_cmd=() - - if am_i_root; then - repmgr_cmd=("run_as_user" "$POSTGRESQL_DAEMON_USER" "${REPMGR_BIN_DIR}/repmgr") - else - repmgr_cmd=("${REPMGR_BIN_DIR}/repmgr") - fi - - debug_execute "${repmgr_cmd[@]}" "$@" + debug_execute "repmgr_execute_print_output" "$@" } ######################## @@ -181,7 +194,7 @@ repmgr_get_upstream_node() { info "Querying all partner nodes for common upstream node..." read -r -a nodes <<<"$(tr ',;' ' ' <<<"${REPMGR_PARTNER_NODES}")" for node in "${nodes[@]}"; do - # intentionally accept inncorect address (without [schema:]// ) + # intentionally accept incorrect address (without [schema:]// ) [[ "$node" =~ ^(([^:/?#]+):)?// ]] || node="tcp://${node}" host="$(parse_uri "$node" 'host')" port="$(parse_uri "$node" 'port')" @@ -926,3 +939,31 @@ repmgr_initialize() { repmgr_register_witness fi } + +######################## +# Checks repmgr status trying to detect split-brain scenarios +# Globals: +# REPMGR_* +# Arguments: +# $1 - property +# $2 - value +# $3 - Path to configuration file (default: $REPMGR_CONF_FILE) +# Returns: +# None +######################### +repmgr_check_status() { + local -r flags=("-f" "$REPMGR_CONF_FILE") + + repmgr_role=$(repmgr_execute_print_output "${flags[@]}" node check --role --nagios | awk '{print $NF}') + if [[ "$repmgr_role" = "primary" ]]; then + # Split-brain case: this node considers himself a primary but + # there's another primary node in the cluster + repmgr_status=$(repmgr_execute_print_output "${flags[@]}" daemon status) + if grep -q "registered as standby but running as primary" <<< "$repmgr_status"; then + echo "inconsistent repmgr status" + return 1 + fi + fi + + return 0 +}